我写了一个web服务,它将TP-Open Service的XML响应转换为JSON格式。我是WCF和编写Webservice的新手。 但是转换后的JSON格式如下所示。如何从C#中的JSON响应中删除反斜杠?
"{ \"data\": { \"current_condition\": [ {\"cloudcover\": \"25\", \"humidity\": \"48\", \"observation_time..
如何删除这些反斜杠\和我的代码到目前为止。
public string checkweather(string q, string num_of_day)
{
HttpWebRequest request=..;
...
string Url = string.Format("http://free.worldweatheronline.com/feed/weather.ashx?q={0}&format={1}&num_of_days={2}&key={3}", q, format, num_of_days, key);
HttpWebRequest Request = (HttpWebRequest)WebRequest.Create(Url);
Request.Method = "GET";
using (HttpWebResponse response = (HttpWebResponse)Request.GetResponse())
{
using (Stream stream = response.GetResponseStream())
{
using (StreamReader reader = new StreamReader(stream))
{
var result2=reader.ReadToEnd();
}}}
return result2;
}
如果您需要更多信息,请通知我。
是RESULT2你正在谈论的字符串?我猜测返回result2.Replace(@“\”,“”); –
这只是从调试复制/粘贴?因为它看起来像反斜杠只是逃避字符 – mihail
@ofstream,我试过但没有改变结果。 – Thiri