serialize json object.

serialize json object.

pricejtpricejt Posts: 12Questions: 5Answers: 1
edited December 2014 in Free community support

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

  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin

    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

  • getkgetk Posts: 2Questions: 1Answers: 0
    edited December 2014
  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin

    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

This discussion has been closed.