converting array to json in javascript code example
Example 1: js array to json
// Array to JSON:
const jsonString = JSON.stringify(yourArray);
// JSON to Object / Array
const yourData = JSON.parse(jsonString);
Example 2: how to convert array to string json
var arr = [ "John", "Peter", "Sally", "Jane" ];
var myJSON = JSON.stringify(arr);