convert json file to datatable in asp.net

Posted by Klbaiju under Others on 7/29/2014 | Points: 10 | Views : 1437 | Status : [Member] | Replies : 1
Hi following is my json file

[ {'id':'10','name':'User','add':false,'edit':true,'authorize':true,'view':true},
{'id':'11','name':'Group','add':true,'edit':false,'authorize':false,'view':true},
{'id':'12','name':'Permission','add':true,'edit':true,'authorize':true,'view':true}
]

My requirement is to convert into a datatable like this

ID | Name | Add | Edit | View | Authorize
---------------------------------------------------------------------
10 | User | true | true | true | true
11 | Group | true | true | true | true
12 | Permission| true | true | true | true
and bind to a grid view.
how it is possible.

thanks in advance
Regards
Baiju




Responses

Posted by: Niravprabtani on: 7/31/2014 [Member] Starter | Points: 25

Up
0
Down
try this.. :)

DataSet dsRecognize = new DataSet();
string jsonStringRecognize = "Json String";
XmlDocument xdRecognize = new XmlDocument();
jsonStringRecognize = "{ \"rootNode\": {" + jsonStringRecognize.Trim().TrimStart('{').TrimEnd('}') + "} }";
xdRecognize = (XmlDocument)JsonConvert.DeserializeXmlNode(jsonStringRecognize);

dsRecognize.ReadXml(new XmlNodeReader(xdRecognize));


http://niravprabtani.blogspot.in/2014/04/how-to-convert-json-string-into-dataset.html

Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response