1

I want transform this json in Dictionary for make one loop

Look my code:

string json = @"{""name"":""Joe"",""note"":{""a1"":10,""a2"":9,""a3"":5}}";

Dictionary<string, object> dictionaryLevelOne = JsonConvert.DeserializeObject<Dictionary<string, object>>(json);   
Dictionary<string, object> dictionaryLevelTwo = JsonConvert.DeserializeObject<Dictionary<string, object>>(dictionaryLevelOne ["note"]);

1 Answer 1

7

You need to pass dictionaryLevelOne["note"] as a string.

string json = @"{""name"":""Joe"",""note"":{""a1"":10,""a2"":9,""a3"":5}}";

Dictionary<string, object> dictionaryLevelOne = JsonConvert.DeserializeObject<Dictionary<string, object>>(json);
Dictionary<string, object> dictionaryLevelTwo = JsonConvert.DeserializeObject<Dictionary<string, object>>(dictionaryLevelOne["note"].ToString());
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.