c# - Serialize complex dictionary with DataContractJsonSerializer -
with .net 4.5 version of datacontractjsonserializer , of datacontractjsonserializersettings.usesimpledictionaryformat can serialize dictionaries. example dictionary:
var dic = new dictionary<string, object> { { "level", 3 }, { "location", "catacomb" } };
will converted nice json:
{ "level":3, "location":"catacomb" }
but if have dictionary value:
var dic = new dictionary<string, object> { { "level", 3 }, { "location", new dictionary<string, object> { { "name", "catacobms" } } } };
the resulted json looks bad:
{ "level":3, "location":[ { "__type":"keyvaluepairofstringanytype:#system.collections.generic", "key":"name", "value":"catacobms" } ] }
is there way fix problem?
ps: know there other json serializers, in case need use datacontractjsonserializer.
try setting emittypeinformation
property on serializer emittypeinformation.never
see msdn entry
Comments
Post a Comment