Newtonsoft.Json 的解析用法。

JsonView是查看和分析json的利器,目录下的Newtonsoft.Json.dll ,我们可以当第三方引用之。

>>>

               //想服务器端发送请求,获取订单信息      
                  myRequest = System.Net.WebRequest.Create(url) as System.Net.HttpWebRequest;
                //--------------------- c#中HttpWebRequest使用Proxy实现指定IP的域名请求 ---------------------------------
                //需要使用Proxy和其配置 (代理ip)                                  
                ////System.Net.WebProxy proxy = new System.Net.WebProxy("115.238.128.138", 80);
                ////myRequest.Proxy = proxy;
                //------------------------------------------------------
                myRequest.Timeout = 1000 * 60 * 1;//1分钟超时  1 minutes timeout
                myRequest.Method = "POST";
                myResponse = myRequest.GetResponse() as System.Net.HttpWebResponse;
                Stream myResponseStream = myResponse.GetResponseStream();
                StreamReader myStreamReader;
                myStreamReader = new StreamReader(myResponseStream, System.Text.Encoding.GetEncoding("utf-8"));
                //post返回的数据
                string receiveData = myStreamReader.ReadToEnd();
                myStreamReader.Close();
                myResponseStream.Close();
                //引用Newtonsoft.Json ,DLL
                JavaScriptObject ListObj = (JavaScriptObject)JavaScriptConvert.DeserializeObject(receiveData);    
                if (ListObj != null)
                {
                    //判断是否存在有效的字符                        
                    if (receiveData.Contains("codeNum"))
                    {
                        JavaScriptArray JsonData = (JavaScriptArray)ListObj["data"];
                        if (JsonData.Count > 0)
                        {
                            for (int m = 0; m < JsonData.Count; m++)
                            {
                                JavaScriptObject orderObj = (JavaScriptObject)JsonData[m];                                
                                string code = orderObj["statusCode"].ToString();
                                
                                JavaScriptArray logsJson = (JavaScriptArray)orderObj["logs"];                               
                                for (int v = 0; v < logsJson.Count; v++)
                                {
                                    JavaScriptObject logsObject = (JavaScriptObject)logsJson[v];
                                    string content=  Convert.ToString(logsObject["content"]) ;
                                    
                                }                              
                            }
                        }
                        
                    }

                }

 

你可能感兴趣的:(json)