0

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.

rudimenter
  • 3,242
  • 4
  • 33
  • 46
  • Can you be more specific with what data you want to retrieve and some examples of how the data might vary? – JohnD Feb 17 '15 at 17:58
  • @JohnD The Question basically explain everything. It can be a object of unknown depth. Json Objects should become OrderedDictionary and Json Arrays should become List. You see the Response class in my description and thats all i have. – rudimenter Feb 17 '15 at 22:20

0 Answers0