javascript json data to array 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: convert json object to array javascript
var as = JSON.parse(jstring);
Example 3: javascript create json object from array
var array = ['a', 1, 'b', 2, 'c', 3],
object = {},
i
for (var i = 0; i < array.length; i += 2) {
object[array[i]] = array[i + 1];
}
console.log(object);