有没有更好的方法来做到这一点?是否有更简洁的方式来使用JavaScriptSerializer.Deserialize(json)?
JavaScriptSerializer jss = new JavaScriptSerializer();
Dictionary<string, object> dic =
jss.Deserialize<Dictionary<string, object>>(json);
Dictionary<string, object>.Enumerator enumerator = dic.GetEnumerator();
enumerator.MoveNext();
ArrayList arr = (ArrayList)enumerator.Current.Value;
foreach (Dictionary<string, object> item in arr)
{
string compID = item["compID"].ToString();
string compType = item["compType"].ToString();
}
我要的是我的项目(即补偿)
我送一个JSON像这样的数组:
{ "comps" : [ { compID : 1 , compType : "t" } , { ect. } ] }
有几个第三方库,将帮助清理:尝试http://json.codeplex.com/和http://www.codeproject.com/Articles/159450/fastJSON – Liam