C# 如何接受服务器返回的Json数据?
2个回答
展开全部
public static string GetHTTPInfo(string urlPath, string eCode, int millisecond)
{
string str = null;
HttpWebResponse response = null;
StreamReader reader = null;
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(urlPath);
request.Timeout = millisecond;
response = (HttpWebResponse)request.GetResponse();
reader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.GetEncoding(eCode));
str = reader.ReadToEnd();
}
catch
{
str = "";
}
finally
{
if (reader != null)
{
reader.Close();
reader.Dispose();
}
if (response != null)
{
response.Close();
}
}
return str;
}
2013-12-16
展开全部
using Newtonsoft.Json;
string jsonstr = context.Request["jsonstr"];
JArray javascript = (JArray)JsonConvert.DeserializeObject(jsonstr);
用Newtonsoft.Json;
string jsonstr = context.Request["jsonstr"];
JArray javascript = (JArray)JsonConvert.DeserializeObject(jsonstr);
用Newtonsoft.Json;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询