Salve ho realizzato un wbservice c# che leggendo dati da database restituisce una stringa json soltanto che la stringa restituita pur acendo la struttura json contiene intestazione xml come posso non farli comparire il codice è tipo questo sotto indicato
codice:[WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public string getData() { JavaScriptSerializer ser = new JavaScriptSerializer(); var jsonData = new { total = 1, // we'll implement later page = 1, records = 3, // implement later rows = new[]{ new {id = 1, cell = new[] {"1", "-7", "aa", "bb"}}, new {id = 2, cell = new[] {"2", "15", "cc", "dd"}}, new {id = 3, cell = new[] {"3", "23", "ff", "gg"}} } }; return ser.Serialize(jsonData); //products.ToString(); }
codice:<?xml version="1.0" encoding="utf-8" ?> <string mlns="http://tempuri.org/"> { "total":1, "page":1, "records":3, "rows": [ {"id":1,"cell":["1","-7","aa","bb"]}, {"id":2,"cell":["2","15","cc","dd"]}, {"id":3,"cell":["3","23","ff","gg"]} ] } </string>

Rispondi quotando