【发布时间】:2015-01-21 04:31:13
【问题描述】:
这是我的代码:
Uri myUri = new Uri("my url");
HttpWebRequest request = (HttpWebRequest)WebRequest.Create (myUri);
// Set some reasonable limits on resources used by this request
request.MaximumAutomaticRedirections = 4;
request.MaximumResponseHeadersLength = 4;
// Set credentials to use for this request.
request.Credentials = CredentialCache.DefaultCredentials;
HttpWebResponse response = (HttpWebResponse)request.GetResponse ();
Console.WriteLine ("Content length is {0}", response.ContentLength);
Console.WriteLine ("Content type is {0}", response.ContentType);
// Get the stream associated with the response.
Stream receiveStream = response.GetResponseStream ();
// Pipes the stream to a higher level stream reader with the required encoding format.
StreamReader readStream = new StreamReader (receiveStream, Encoding.UTF8);
Console.WriteLine ("Response stream received.");
Console.WriteLine (readStream.ReadToEnd ());
response.Close ();
readStream.Close ();
响应应该是这样的:
[
{
"book_name": "CYRILLIC LETTERS",
"book_id": "Text",
},
{
"book_name": "CYRILLIC LETTERS",
"book_id": "Text",
},
]
StreamReader.ReadToEnd() 正在返回我想要的所有内容,但它将西里尔字母替换为数字,例如:\u041c\u0410\u0422\u0422\u041e
我应该怎么做才能正确获取所有内容?
【问题讨论】: