Deserialize complex JSON arrays

Jun 29, 2010 at 12:05 AM

Hi,

I am trying to deserialize multi-dimentional json arrays with Json.NET.

With data like the following (I have no control over the returned data),

[  [      "1234",      "abcd",      "1234"  ],  [      "2345",      "bcde",      "2345"  ],  [      "3456",      "cdef",      "3456"  ]]

I used the following, and it worked perfectly.

List<List<string>> data = (List<List<string>>)JsonConvert.DeserializeObject(json, typeof(List<List<string>>));

However, I also have to deal with data like (Key1, Key2, Key3, Key4 (array)):

[  [      "1234",      "abcd",      "1234",      [ "1", "3", "4" ]  ],  [      "2345",      "bcde",      "2345",      [ "4" ]  ],  [      "3456",      "cdef",      "3456",      []  ]]

Note: the last value is another array.

Is there a way to deserialize using Json.NET? I tried creating a class, but it didn't work.

Help and thx