I am receiving the following example Json message which could be deeply nested. How deep is not known in advance.
{
"body": {
"blmRequest": {
"events": [
{
"event": "Login",
"params": [
{
"key": "pin",
"value": "xxxx"
},
{
"key": "version",
"value": "xxxxxx"
},
{
"key": "NFC",
"value": "x"
}
]
},
{
"event": "TCD_Recargaxxxx",
"params": [
{
"key": "amt",
"value": "xx"
},
{
"key": "cel",
"value": "xxxx"
},
{
"key": "pin",
"value": "xxxx"
},
{
"key": "version",
"value": "xxxxxx"
},
{
"key": "NFC",
"value": "x"
}
]
}
]
}
}
}
I want to deserialize the Json into my class. which work as a kind of Root object:
public class Response
{
public OrderedDictionary<string, object> body { get; set; }
}
The class OrderedDictionary<string,object>
is a custom Dictionary which i would like to use for all Json Objects which are found during traversing the deep hierarchy. The Standard class List<object>
i would like to use for all Json Arrays which will be found during Traversing the hierarchy. All other Simple types should be saved as plain objects.
Unfortunately Json.Net gives up after one level deep and returns as value of the Dictionary a JObject hierarchy.
I can't use ExpandoObject
as value of OrderedDictionary
either.
What and How i can overwrite in Json.Net to make my scenario work. I would like to use Json.Net Extension possibilities only.