1var person={"first_name":"Tony","last_name":"Hawk","age":31};
2var personJSONString=JSON.stringify(person);
1var jsonPerson = '{"first_name":"billy", "age":23}';
2var personObject = JSON.parse(jsonPerson); //parse json string into JS object
1var jsonArray = '{"required":1, "minlength":2}'
2var jsonParsedArray = JSON.parse(jsonArray);
3for (key in jsonParsedArray) {
4 if (jsonParsedArray.hasOwnProperty(key)) {
5 console.log("%c "+key + " = " + jsonParsedArray[key],"color:cyan");
6 }
7}
1var myObj, x;
2myObj = {"name":"John", "age":30, "car":null};
3x = myObj.name;
4document.getElementById("demo").innerHTML = x;