当前位置: 代码迷 >> Web Service >> C# 读取Json内的数据,中文乱码,怎么解决
  详细解决方案

C# 读取Json内的数据,中文乱码,怎么解决

热度:898   发布时间:2013-09-12 22:07:00.0
C# 读取Json内的数据,中文乱码,如何解决?
我把代码贴出来,大家看看!
这是网上找的一段代码


   private string getJson()
        {
            string url="http://218.228.332.114:8089/order/xxxxxx?prodid=330006";
            string addressBookStr1 = null;//存放整个的字符串
            HttpWebRequest addressRequest;//
            HttpWebResponse addressResponse;//请求回应
            try
            {
                
                addressRequest = (HttpWebRequest)WebRequest.Create(url);
                addressRequest.Method = "GET";
                addressResponse = (HttpWebResponse)addressRequest.GetResponse();
                string t = addressResponse.ContentType;
                string c = addressResponse.ContentEncoding;
                Stream addressStream = addressResponse.GetResponseStream();
                Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
                StreamReader readStream = new StreamReader(addressStream, encode);
                Char[] read = new Char[256];  
                int count = readStream.Read(read, 0, 256);
                String str = "";
                while (count > 0)
                {
                    // Dumps the 256 characters on a string and displays the string to the console.
  相关解决方案