Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm using a web service in C# and SQL Server with a stored procedure. The web service code is in the XML format. I need to convert the code to JSON format for using in AngularJs. Or is there any possibility to return the web service data in JSON format?

What I have tried:

This is my Output

HTML
<NewDataSet> 
      <Table> 
        <iDept_category_id>6</iDept_category_id> 
        <cDept_category>qaz</cDept_category> 
        <dcreate_dt>01 Jan 2016</dcreate_dt> 
      </Table> 
      <Table> 
        <iDept_category_id>7</iDept_category_id> 
        <cDept_category>ICU</cDept_category> 
        <dcreate_dt>01 Dec 2016</dcreate_dt> 
      </Table> 
   </NewDataSet>


I need this output in

{"NewDataSet":
{"Table":[
{
"iDept_category_id":"6",
"cDept_category":"qaz",
"dcreate_dt":"01 Jan 2016"
},
{
"iDept_category_id":"7",
"cDept_category":"ICU",
"dcreate_dt":"01 Dec 2016"
}
]}
}
Posted
Updated 19-Dec-16 20:57pm
v2
Comments
F-ES Sitecore 20-Dec-16 4:41am    
It'll be easier to make the werbservice return json. Google "asmx webservice return json".

1 solution

Converting from XML to JSON is a common task, you may find a lot of material on the web. See, for instance: c# - How to convert JSON to XML or XML to JSON? - Stack Overflow[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900