• 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"]) ;
                                        
                                    }                              
                                }
                            }
                            
                        }
    
                    }
  • 相关阅读:
    网站开发动静分离
    如何前后端分离?
    设置HTML编码为UTF-8
    数据库索引&数据页
    spring中的BeanFactory和FactoryBean的区别与联系
    Java可重入锁与不可重入锁
    abo dto属性验证的坑
    小程序如何去掉button组件的边框
    asp.net core使用gzip
    npm总结
  • 原文地址:https://www.cnblogs.com/Fooo/p/3441140.html
Copyright © 2020-2023  润新知