我希望 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>
答案 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);
}