c# - Incorrect deserialisation of a generic list using ServiceStack.Text -
i'd ask if following behaviour - either v3 (bsd) or v4 - bug.
i have generic list. serialise using mylist.tojson(). result this:
"[{\"__type\":\"mynamespace.mytype, myassembly\", ... (properties)}, {... (properties)}, {... (properties)}, {... (properties)}, ...]" that is, first element has type written. result, when this:
var deserialised = mylist.tojson().fromjson<list<object>>(); i list has first element mytype , subsequent elements strings. know that:
fromjson<list<mytype>>() works don't know type @ compile time. have 2 questions:
- is bug?
- if not, there way can work around without overhead of dynamic parsing (i.e. jsconfig.includetypeinfo)?
the reason above is:
jsstate.iswritingdynamic = false; at:
if (writetypeinfo != null || jsstate.iswritingdynamic) { if (jsconfig.preferinterfaces && trywriteselftype(writer)) i++; else if (trywritetypeinfo(writer, value)) i++; jsstate.iswritingdynamic = false; } in:
writetype<t, tserializer>.writeproperties that line added @ 067ce1f62fc6addd3685a2134dd576529db2549f on 9.12.2012 remove types of properties themselves. think previous value of iswritingdynamic should restored after writing of properties, is, before end of same method. please confirm this?
Comments
Post a Comment