Asp.Net解析json字符串
方法一:
using LitJson;
string json= "{...........}"; JsonData jdData = JsonMapper.ToObject(json); Response.Write(jdData.Count); JsonData jdItems = jdData["data"]; foreach (JsonData item in jdItems) { string url = item["name"].ToString(); Response.Write(url + "<br>"); }
方法二:
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
string jsontext = "[{......}]"; JArray ja = (JArray)JsonConvert.DeserializeObject(jsontext ); JArray jaWenda = (JArray)ja[0]["data"]["ww"]; foreach (JObject item in jaWenda) { string title = item["question"]["title"].ToString(); JArray jaconPic = (JArray)item["question"]["content"]["pic_uri_list"]; Response.Write(title .ToString()); }
//成功一定有方法,失败一定有原因。