KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I saw a similar question but it did not resolve my issue. I have a JSON web service in an ASMX file; The code for the web method [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public string GetUserRoles(string JSONUserCode) { string retRoles = string.Empty; List<JSONRole> roles = new List<JSONRole>(); {... I Populate the roles here ...} DataContractJsonSerializer serializer = new DataContractJsonSerializer(roles.GetType()); MemoryStream ms = new MemoryStream(); serializer.WriteObject(ms, roles); string jsonString = Encoding.Default.GetString(ms.ToArray()); ms.Close(); return jsonString; } This correctly formats the List correctly but wraps the entire return in XML. Here is the response: <?xml version="1.0" encoding="utf-8" ?> <string xmlns="http://formshare.com/"> [{"Name":"Accounts Payable"},{"Name":"Payroll"}] </string> You can view the Response your self by clicking this link: http://dev.formshare.gologictech.com/JSON/JSONService.asmx/GetUserRoles?JSONUserCode=1234 I need the response to be just: [{"Name":"Accounts Payable"},{"Name":"Payroll"}] Any ideas? Thanks for your help.
Tags (comma-separated)
Save Edits
Cancel