有没有更好的方法来做到这一点?
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();
}
我想要的只是我的物品数组(即comp)
我正在发送这样的json:
{ "comps" : [ { compID : 1 , compType : "t" } , { ect. } ] }