Christian Gerlach Christian Gerlach - 1 year ago 135
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 Source

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