How can I export data to json formatted?
How can I export data to json formatted?
Hello, I'm struggling to export data in json format through a button, the thing is that I want it formatted, something like this:
{
"Column2": "Cliente",
"Column3": "Razon Social",
"Column4": "Ref Producto",
"Column5": "Descripcion Producto",
"Column6": "Cantidad",
"Column7": "Monto Total",
"Column8": "Codigo Familia",
"Column9": "Nombre Familia",
"Column10": "Linea Producto",
"Column11": "Nombre de Linea",
"Column12": "Categoria"
},
WebDataRocks wont accept the regular json format that the json button in the documentation creates.
Thanks in advance!
Answers
I'm not sure what JSON button you are referring to. There isn't one a built in button for JSON.
You can create a Custom Button like this example. In the custom button you can fetch the table data, using
rows().data()
or loop through the table data usingrows().every()
and build the data structure you need.Kevin
I got the button from this link
https://datatables.net/extensions/buttons/examples/html5/customFile.html
I'll try the options you gave me to build a json formatted, thanks!
I see. That is a custom button. If you need a different format than what JSON.stringify() provides you will need to loop through the
data
variable from line 8 to create the structure you want.Kevin
What format do you need?