Convert my Datatable to a JSON
Convert my Datatable to a JSON
oakmese
Posts: 9Questions: 4Answers: 0
Hi,
I want to know if it's possible ton convert the datas of my Datatable to a JSON ?
This question has an accepted answers - jump to answer
Answers
Use
rows().data()
withtoArray()
chained to get a Javascript array of rows. You can then useJSON.stringify()
to convert to a JSON string. For example:Kevin
Tank you @kthorngren
I have div,span, img... in my table, I think the best solution is to get the JSON from the export option of excel do you think it's possible ?
The Excel format is in OpenXML and not conducive to obtaining the raw data.
I would look at using
rows().every()
to iterate all the rows and build a new array with the manipulated data. Use a regular expression to remove the HTML tags from the appropriate columns. Stack Overflow is a good resource for regex expressions.I forgot to mention if you use
ajax
you can useajax.json()
to get the last fetched data.Kevin
thank you @kthorngren