js object array to json code example
Example 1: turn object into string javascript
var obj = {a: "a", b: "b" };
var string = JSON.stringify(obj);
Example 2: Javascript object to JSON string
var person={"first_name":"Tony","last_name":"Hawk","age":31};
var personJSONString=JSON.stringify(person);
Example 3: convert json.stringify to array in javascript
const myObj = {
name: 'Skip',
age: 2,
favoriteFood: 'Steak'
};
const myObjStr = JSON.stringify(myObj);
console.log(myObjStr);
console.log(JSON.parse(myObjStr));
Example 4: convert json object to array javascript
var as = JSON.parse(jstring);