serialize json object.
serialize json object.
I am storing values in XML document that I later use in jquery datatables. I would like to convert the xml to Json and load that into datatables. I had this all working until some of the data that had to be stored in the xml had to be encoded. I used xmlconvert.encodename to convert the data. This solved the problem on the data storing correctly on the xml side.
However now I need to decode the values when I convert the string to json so that it shows up in the datatable grid without the encoding. Need some help on how to do this.
var ds = new DataSet();
ds.ReadXml(Server.MapPath("App_Data\\" + databaseName + ".xml"));
//var doc = new XmlDocument();
//doc.Load(Server.MapPath("App_Data\\" + databaseName + ".xml"));
var dt = ds.Tables["record"];
var jsonText = JsonConvert.SerializeObject(dt);
return jsonText;
This works however the data shows up with the xmlconvert.encodename text so it looks weird.
Error_x0020_during_x0020_rules_x0020_processing:_x000A
If someone could give me a hand i would appreciate it.
Thanks
Answers
I'm afraid I don't know. It might be worth asking on StackOverflow or the MSDN forums about this since it is specific to the server-side code, rather than the Javascript library.
Allan
You mean to Stringify it?
var jsonText = JSON.stringify(dt);
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
If your code above in Javascript, then yes. However, it looks a bit like C# to me (based on the name of the JSON library), so I don't see what good a Javascript function would do you.
Allan