Analyze json data to a dynamic object

advertisements

I am trying to parse following json data, but I get following error:

Invalid array passed in, ',' expected. (19): { '2': { '2_1': [0: 244, 1: 837], '2_2': [0: 333, 1: 444] } }

Code

var jsonData = @"{ '2': { '2_1': [0: 244, 1: 837], '2_2': [0: 333, 1: 444] } }";
JavaScriptSerializer j = new JavaScriptSerializer();
var x = (Dictionary<string, List<object>>)j.DeserializeObject(jsonData);

Any help?

UPDATE:

Changed to:

string jsonData = @"{ 'Two': { 'Two_1': [{0: 244}, {1: 837}], 'Two_2': [{0: 333}, {1: 444}] } }";

but now I get following error:

Unable to cast object of type System.Collections.Generic.Dictionary'2[System.String,System.Object] to type System.Collections.Generic.Dictionary'2[System.String,System.Collections.Generic.List'1[System.Object]].


You have invalid JSON. If you have array of objects, then it should look like

[{'0' : 244}, {'1': 837}]

See JSON syntax:

An object is an unordered set of name/value pairs. An object begins with { (left brace) and ends with } (right brace). Each name is followed by : (colon) and the name/value pairs are separated by , (comma).

Also keep in mind that names should be strings.


Correct JSON:

{'2': {'2_1': [{'0': 244}, {'1': 837}], '2_2': [{'0': 333}, {'1': 444}]}}