net-feature-tests
net-feature-tests copied to clipboard
[question] serializers features: dictionary
hi please explain me what does "Sometimes it is inconvenient or impossible to define schema as a static type in advance. This leaves two options -- dictionaries and dynamic types." mean
is it some kind of schema additional initialization through defining a dictionary for it, or dictionary referencing to Collections.Dictionary, or something else? as it is mentioned along with dynamic types it leads me to thinking, that Dictionary is included as field of serialized object.. but it doesn't make much sense, considering json will serialize dictionary as container (but if it can be 'flattened', that makes sense, tho)
also the term 'roundtrip'. i understand roundtrip as process of decerializing/serializing in one. is it that or smth else meant? what is the point of it in considered context?
Those are basically tests on IDictionary support (they test top level, but a property of an object should a also work). The main problem with those tests is that for XML there is no single well-defined dictionary format.
Roundtrip comes from that fact -- I just give a dictionary to the serializer, then give result back to the deserializer, without checking the intermediate string.
"Clean" is when I give them a predefined format -- which is clear for the JSON, but for XML it might not make much sense at the moment.
it's actually strange json.net can't handle nested dictionaries even with explicitly predefined format o_O
It doesn't fail completely, but it produces a JObject instead (which does not implement IDictionary<string, object>
). This is super annoying if you want to use it in e.g. WebApi without having to handle Json.Net-specific types.
In fact in my current work I have a replacement object converter for Json.Net just to force it to generate IDictionary for nested objects (and for better dynamic casts).
I'll think on how I can clarify the labels a bit more.