1

Closed

Apply JsonDictionaryAttributes to properties

description

It would be nice if the JsonDictionaryAttribute could be applied to properties so I could do things like
 
class MyDataObject {
[JsonDictionary(ItemConverterType(typeof(MyCustomItemConverter)]
public Dictionary<string, int> MyCustomSerializedCollection { get; set; }
}
Closed May 5, 2012 at 9:48 AM by JamesNK
Done. Its added to JsonProperty rather than JsonDictionaryAttribute, i.e. [JsonProperty(ItemConverterType = typeof(BlahConverter))]

comments

erikkallen wrote Apr 27, 2012 at 12:50 PM

I know it is intended to be put on a class, that is the problem. It would be (IMO) much more useful to put it on a property, as it is rather unusual to implement dictionary classes, but very common to use them.

Might be too complicated, though, I don't know.

ejball wrote May 1, 2012 at 7:17 PM

I agree; the ability to customize the converter for the items of an array or dictionary property would be extremely useful. To make matters worse, I have not been able to discover any sort of workaround.

JamesNK wrote May 3, 2012 at 1:22 PM

That attribute is designed to be put on a class, not property. Also too complicated to implement.



** Closed by JamesNK 4/27/2012 4:38 AM

JamesNK wrote May 3, 2012 at 1:22 PM

By popular demand. Also I had an idea of how this could be done.