Serialize All DataTable Data (All Rows) to a JSON String

Serialize All DataTable Data (All Rows) to a JSON String

Eugene_BEugene_B Posts: 19Questions: 8Answers: 0

I need to stringify the entire DataTable into a JSON string.

But this gives an error:
var allDataStr = JSON.stringify($('#advanced_search_results').DataTable().rows().data());

I thought, first I can do $('#..').DataTable().rows().data() for the full JSON object, then JSON.stringify.

The error is:
Uncaught TypeError: Converting circular structure to JSON

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,172Questions: 26Answers: 4,923
    Answer ✓

    You might need to chain toArray(), something like this:
    JSON.stringify($('#advanced_search_results').DataTable().rows().data().toArray());

    Kevin

This discussion has been closed.