json比一般格式再复杂点的就像数组一样,有多层嵌套,研究了一下,记录代码如下:
string jsonText = "{'name':'test','phone':'18888888888','image':[{'name':'img1','data':'data1'},{'name':'img2','data':'data2'},{'name':'img3','data':'data3'}]}";
JObject jo = (JObject)JsonConvert.DeserializeObject(jsonText);
string zone = jo["name"].ToString();
string zone_en = jo["phone"].ToString();
JArray jar = JArray.Parse(jo["image"].ToString());
MessageBox.Show(zone);
MessageBox.Show(zone_en);
for (var i = 0; i < jar.Count; i++)
{
JObject j = JObject.Parse(jar[i].ToString());
MessageBox.Show(j["name"].ToString());
MessageBox.Show(j["data"].ToString());
}