Several nullable .Net properties serializing to one json property

Oct 28, 2012 at 10:52 PM

I'm trying to use to generate  json objects that can be used as a settings object  for jquery ui widgets like accordion, autocomplete etc...

Now some properties of these widgets allow mutliple types for on property.

In this case I would want an attribute like the JsonProperty attribute, but one the allows me to have the same name on serveral properties. On my class I check that only one of these properties is not null. 

e.g. for the jquery ui accordion widget, the active property can be a bool or an int.
so I would have 2 properties on my  .Net object : bool? IsActive, int? ActivePanel.
If IsActive is not null, it should be serialized with the name "active" as a bool
If ActivePanel is not null, it should be serialize with the name "active" as an int

Any suggestions? The current JsonProperty throws an error if I have 2 properties with the same name.
In my case there will be only serialisation, so deserialization is no issue.