0

i have a webservice (wsdl) generated from a java project. its output is getting as json format. something like this [{"pid":163686,"chartno":null,"lName":"Bec&&kwith","fName":"Burt","mName":null,"line1":"312 HILL ROAD","line2":null,"city":"Hillsboro","state":"Missouri","pinCode":null,"phone":"123456879","dob":"1947-01-01","gender":"Male","ssn":null,"martialStatus":null,"guarantor":null,"sig":null,"priInsname":null,"priPolNo":null,"secInsname":null,"secPolNo":null}]

i want to use this data in my c# web application to display it in a grid.. how can i get this data into a datatable? how to format the json output to a table structure if multiple data comes?

The heading will be pid, chartno, ... etc .

i dont want to make it too complex... i just want the json output to store into a dictnory or somthing .. thank u

Sharon
  • 757
  • 6
  • 21
  • 44

2 Answers2

1

I would deserialize the JSON in to a custom c# object instead of a DataTable.

Deserialize JSON string to c# object

Essentially you can use the JavaScript serializer to deserialize your JSON string into the object. I recommend this over the data table since you would have to manually map it to the table The grid should be able to consume a List of your custom object instead of a data table

Community
  • 1
  • 1
TGH
  • 38,769
  • 12
  • 102
  • 135
  • Indeed. A DataTable is a bloated object made for other purposes. Ultimately all you need of it here is its quasi-collection properites. – Andrew Barber Oct 30 '13 at 05:38
  • yes. i only need the data from json to map to any of the collections in c#. how can i do it with in the boundary of .net framework 3.5 without using any of the external dlls – Sharon Oct 30 '13 at 05:42
1

You need to Parse json , you can JQuery to parse json object.

Priya Gund
  • 156
  • 5