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());
            }
        

 

posted @ 2017-10-10 22:56  WebApi  阅读(2379)  评论(0编辑  收藏  举报
CopyRight © 博客园 WebAPI