2

I have a json array:

{
 "array":[
      {
       "Name_0":"Value_0",
       "Name_1":"Value_1"
      },
      {
       "Name_2":"Value_2",
       "Name_3":"Value_3",
       "Name_4":"Value_4",
       "Name_5":"Value_5"
      }
 ]
}

The data structures inside the json array are not consistent. How can I parse them in C#? Thanks!

alexrad
  • 21
  • 3

1 Answers1

0

One way to do this will be

var serializer = new JavaScriptSerializer();
var data = serializer
    .Deserialize<Dictionary<string, List<Dictionary<string, string>>>>(input);

This is because your json data structure is like this. For innermost element we have a Dictionary<string, string> which is nested in a generic list which in turn is nested in another generic dictionary.

naveen
  • 53,448
  • 46
  • 161
  • 251