Christian Gerlach Christian Gerlach - 5 months ago 13
JSON Question

JSONify array of arrays

Just looking for some input on best practice.
I have an array containing arrays. Call it array1.
array1 contains arrays of strings.
What is the cleanest way to JSONify array1 as a string?
Thanks everyone.

**Edited -- I need array1 as a JSON string.

Answer

use JSON.stringify to convert an object (json) to a string and simply provide the correct object (arr).

var arr = [["1","2","3"],["4","5","6"]];

var arrStr = JSON.stringify(arr); // simply stringify
console.log(arrStr);