kapil gupta
kapil gupta

Reputation: 21

How to remove string node from json response

I want to get this JSON response without string node in ASP.net webservice.

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

Upvotes: 2

Views: 1611

Answers (1)

Sain Pradeep
Sain Pradeep

Reputation: 3125

Just change the method return type to void and write string with the Response.Write() method like this.

[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);


}

Upvotes: 3

Related Questions