1

Closed

Custom JsonConverter does not respect ItemTypeNameHandling option

description

After adding a custom JsonConverter using ItemConverterType which just calls serializer.Serialize(writer, value) and serializer.Deserialize(reader, objectType) (pass through without adding any new functionality), Json.NET stops generating $type property, even though ItemTypeNameHandling is set to Auto/All.

Example can be found in StackOverflow question: http://stackoverflow.com/questions/14182961/making-custom-jsonconverter-respect-itemtypenamehandling-when-serializing-with-json-net

The workaround is probably to change serializer.Serialize call to creating JObject and adding a $type property manually, but it will probably be considerably slower, and I think options set via attributes should still work even with custom converters if they use just serializer.Serialize.
Closed Jan 23, 2013 at 5:41 AM by JamesNK
Afraid a JsonConverter doesn't know about what context it is called under.

comments