Custom json.net serializer / deserializer for ExpandoObject special key

I want to serialize and deserialize ExpandoObject with non-trivial values. Some ExpandoObject values ​​contain objects with properties leading to circular references.

I wrote a custom serializer / deserializer for these objects. However, these objects are found in many places in ExpandoObject (also nested not only at the root level). But they always have the same key! I want the deserializer to take my own deserializer for each ExpandoObject property of a specific key.

For example:

{
    "a": 12.5,
    "b": "hello world",
    "special": { /* ... */ },
    "c": -4,
    "d":
        {
            "x": "test",
            "special":  { /* ... */ },
            "y": 152
        },
    "e": 9053
}

      

I want every feature to be deserialized with my custom deserializer in my class. Everything else should be handled by the default deserializer.

Am I on the right track to deal with my problem? If so, how can I achieve this using JSON.NET?

+3


source to share





All Articles