I am developing a ASP .Net Web service. I want the data in JSON format.
But I am getting only partial results.
This is about the environment.
Microsoft Visual Studio 2008 Version 9.0.21022.8 RTM Microsoft .NET
Framework Version 3.5Installed Edition: Professional
I have included the following in my code.
using System.Web.Script.Services;
using System.Web.Script.Serialization;
This is the method I am using:
[WebMethod(EnableSession = true)]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string getDeviceTokens()
{
ArrayList list = (ArrayList)Session["Session"];
//String s =(String) Session["Session"];
return new JavaScriptSerializer().Serialize(list);
}
The result I am getting is:
<string>["one","two"]</string>
I need the response as
[“one”,”two”]
What is the problem here?
Is there any other setting I need to do?
UPDATE:
The output I am getting is <string>["one","two"]</string>
I’ve tried to test your problem on local web service included in same project as class from which I am calling this web service and everything works fine. I am getting output without
I am also using something like this on more complex data and everything works fine (even when calling this service from ajax)