2

I have problems with parsing JSON.

JSON

[
 {
   "obj" :
    {
    "id" : 2001,
    "modified" : 1365551172.000000000,
    "size" : 19,
    }
 },{
   "obj2" :
    {
    "id" : 2001,
    "modified" : 1365551790.000000000,
    "size" : 19,
    }
 }
]

when I try to parse with

 var dict = jss.Deserialize<Dictionary<string, Dictionary<string, dynamic>>>(string);
 var json = jss.Serialize(dict);

there is an exception, that arrays couldn't be parsed. Is there anything I have overseen ? Is there any other library to use and how?

2
  • 3
    I believe it should be var dict = jss.Deserialize<List<Dictionary<string, Dictionary<string, dynamic>>>>(string); Commented May 7, 2013 at 8:13
  • 1
    You were right. Ok don't rely on resharper :D Commented May 7, 2013 at 8:26

1 Answer 1

3

How about using Json.Net ?

dynamic jObj = JsonConvert.DeserializeObject(jsonstring); 

var id = jObj[0].obj.id;

or

var jObj = JsonConvert.DeserializeObject<JArray>(json);

var id = jObj[1]["obj2"]["system::ownerUserId"];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.