【问题标题】:How to remove string node from json response如何从json响应中删除字符串节点
【发布时间】:2015-04-16 06:27:06
【问题描述】:

我想在 ASP.net webservice 中获得这个没有字符串节点的 JSON 响应。

<string xmlns="http://tempuri.org/">
[{"bookname":"Love Stories","name":"Vave Microtech","email":"anilkumar@vavemicrotechtt.com","mobile":"918010066285","address":"Sushant tower sec-56, Gurgaon (India)","nearestarea":"gurgaon"},]
</string>

【问题讨论】:

  • 你是如何处理结果的?

标签: asp.net web-services


【解决方案1】:

只需将方法return type 更改为void 并像这样使用Response.Write() 方法写入字符串。

[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public void TestMethod()
{
   // your actual Json  
   string srtJson="[{\"bookname\":\"Love Stories\"}]";

   HttpContext.Current.Response.ContentType = "text/xml";
   HttpContext.Current.Response.Write(srtJson);


}

【讨论】:

  • HttpContext.Current.Response.ContentType = "text/xml";
猜你喜欢
  • 2012-07-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-12-27
  • 1970-01-01
  • 2017-01-18
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多