【发布时间】:2014-05-30 10:19:28
【问题描述】:
我正在使用 Newtonsoft 和 Newtonsoft.Json。我有以下 json:
string strJson_StorageInfo = "[{10:\"test\"}, {20:\"test1\"}]";
List<Dictionary<int, string>> jobj = (List<Dictionary<int, string>>) JsonConvert.DeserializeObject(strJson_StorageInfo, typeof(List<Dictionary<int, string>>));
foreach (Dictionary<int, string> dicStorageInfo in jobj) {
foreach (KeyValuePair<int, string> StorageItem in dicStorageInfo) {
Response.Write("key : " + StorageItem.Key + " , value : " + StorageItem.Value + "</br>");
}
}
我需要反序列化这个。谁能给我推荐一个好方法。提前致谢
【问题讨论】:
-
我在这里只看到一个字符串,没有使用 Newtonsoft。你是在序列化上面的 JSON 吗?
-
List
> jobj = (List >) JsonConvert.DeserializeObject(strJson_StorageInfo, typeof(List >)); foreach (Dictionary dicStorageInfo in jobj) { foreach (KeyValuePair StorageItem in dicStorageInfo) { Response.Write("key : " + StorageItem.Key + " , value : " + StorageItem.Value + " ");我觉得对列表对象和字典对象进行不必要的枚举。
标签: c# json.net deserialization