private void testbtn_Click(object sender, RoutedEventArgs e)
{
string url = "http://api.eve-central.com/api/evemon";
var request = WebRequest.Create(url);
request.ContentType = "application/json; charset=utf-8";
string text;
var response = (HttpWebResponse)request.GetResponse();
using (var sr = new StreamReader(response.GetResponseStream()))
{
text = sr.ReadToEnd();
}
var data = JObject.Parse(text);
string finalized = data.ToString();
我试图解析一个json响应来获取~6个字段中的字符串/ int值,但由于某种原因,程序会挂起:
text = sr.ReadToEnd();
如果有行:
var data = JObject.Parse(text);
存在。如果这些行不存在,该函数可以正常工作(尽管它只是用标记标记打印原始json响应)。有谁知道如何解决这个问题?