json形如
{ "object":{ "name":"cwr" }, "others":"123" }
要获取name的值,则需要构造两个JObject来获取,如下:
JObject json = JObject.Parse(jsonresult); string name = ((JObject)json["object"])["name"].ToString();
json形如
{ "object":{ "name": [ { "firstname" : "cwr", "lastname" : "cwr" } ] }, "others":"123" }
获取firstname的值如下:
JObject json = JObject.Parse(jsonresult); string firstname = ((JObject)((JObject)json["object"])["name"][0])[firstname].ToString();