我想在Dictionary中将这个json转换成一个循环
查看我的代码:
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"]);
答案 0 :(得分:5)
您需要将dictionaryLevelOne["note"]
作为字符串传递。
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());