如何从json响应中删除字符串节点

时间:2015-04-16 06:27:06

标签: asp.net web-services

我希望 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>

1 个答案:

答案 0 :(得分:1)

只需将方法返回类型更改为void ,然后使用 Response.Write()方法编写字符串。

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

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


}