ASP.NET WebMethod Returns JSON wrapped in quotes
Posted
by CL4NCY
on Stack Overflow
See other posts from Stack Overflow
or by CL4NCY
Published on 2010-06-08T14:51:10Z
Indexed on
2010/06/08
15:02 UTC
Read the original article
Hit count: 288
Hi, I have an asp.net page with a WebMethod on it to pass JSON back to my javascript.
Bellow is the web method:
[WebMethod]
public static string getData(Dictionary<string, string> d) {
string response = "{ \"firstname\": \"John\", \"lastname\": \"Smith\" }";
return response;
}
When this is returned to the client it is formatted as follows:
{ \"d\": \"{ \"firstname\": \"John\", \"lastname\": \"Smith\" }\" }
The problem is the double quotes wrapping everything under 'd'. Is there something I've missed in the web method or some other means of returning the data without the quotes? I don't really want to be stripping it out on the client everytime. Also I've seen other articles where this doesn't happen.
Any help would be appreciated thanks.
© Stack Overflow or respective owner