I've asp.net webservice with json returning data, when I call it, it return me data in json but embed it in xml.
What should I do on the server side to ensure that my webservice just returns json?
My .asmx service is as below
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Script.Services;
using System.Web.Script.Serialization;
using System.Text;
using System.Collections;
using System.IO;
using System.Xml;
[WebMethod(Description = "DemoMethod to get Total.")]
public string GetTotal(string a, string b, string c)
{
List<Hashtable> objMyclass = new List<Hashtable>();
JSonOutPutProperties jsonProperty = new JSonOutPutProperties();
//
int total = Convert.ToInt32(a) + Convert.ToInt32(b) + Convert.ToInt32(c);
jsonProperty.Properties.Add("Total", total);
objMyclass.Add(jsonProperty.Properties);
//
JsonOutput objjson = new JsonOutput();
objjson.objectcount = objMyclass.Count;
objjson.objectname = "Total";
objjson.objectvalues = objMyclass;
//
JavaScriptSerializer js = new JavaScriptSerializer();
string strJSON = js.Serialize(objjson);
return strJSON;
}