C# Deserialize Multi-Dimentional JSON array : I am having an issue deserializing and defining this JSON structure would be great to get some assistance. I have reverted this back to last known working position because I am just going off the rails here.

my JSON stucture is:

    [
      {
      "name": "Name1",
      "description": "Description of this process",
      "Location": "ANY",
      "SubItems":       [
                  {
            "name": "sub1",
            "required": true,
            "description": "This is a short description"
         },
                  {
            "name": "sub2",
            "required": true,
            "description": "This is a short description"
         },
                  {
            "name": "sub3",
            "required": true,
            "description": "This is a short description"
         }
      ],
      "outputs":       [
                  {
            "name": "out1",
            "required": false
         },
                  {
            "name": "exit code",
            "required": false
           }
         ]
      },
         {
         "name": "Name2",
         "description": "This is a short description",
         "Location": "ANY",
         "SubItems": [      {
            "name": "sub1",
            "required": false,
            "description": "This is a short description"
         }]
         },
         ]
      }
    ]

Here are my C# Json definitions that were last working.

    public class JsonObject
    {
        [JsonProperty("name")]
        public string ProcessName { get; set; }

        [JsonProperty("description")]
        public string ProcessDescription { get; set; }

        [JsonProperty("Location")]
        public string KnownLocation { get; set; }
    }

I am only capturing a couple of definitions at the moment for testing.

Here is my deserializing object

    var Object = JsonConvert.DeserializeObject <List<JsonObject>>(txt);
                foreach (JsonObject JsonObject in Object)
                {
                    Console.WriteLine("Name: " + JsonObject.ProcessName);
                    Console.WriteLine();
                    Console.WriteLine("Description: " +JsonObject.ProcessDescription);
                    Console.WriteLine();
                }

 
So as I had stated, I can get at least the first 3 top-most level JSON elements in the output. The problem starts when I start trying to get the "SubItems" and "outputs"

I followed the structure of the below linked post and tried very hard to understand it, but after a while I realized that solution is not for this issue. I simply have a multi-dimentional array JSON object. Literally has a top tier, and 2 sub tiers

I attempted to try and do... 

    List<List<JsonObject>>Object = JsonConvert.DeserializeObject <List<List<JsonObject>>>(txt);

and tried to have 2 lists of the same with different names with 3 sets of JSON Definitions.

and implemented the tiered foreach loops, but then I wasn't able to access the definitions for the top most JSON, and nothing was writing for the actual elements for "SubItems"

What I need is to get to each object, really.

http://stackoverflow.com/questions/32896228/how-to-deserialize-a-json-file-with-multidimensional-array-to-convert-it-to-obje

Related Issue

