1var jsonPerson = '{"first_name":"billy", "age":23}';
2var personObject = JSON.parse(jsonPerson); //parse json string into JS object
1const json = '{ "fruit": "pineapple", "fingers": 10 }';
2const obj = JSON.parse(json);
3console.log(obj.fruit, obj.fingers);
1const json = '{"result":true, "count":42}';
2const obj = JSON.parse(json);
3
4console.log(obj.count);
5// expected output: 42
6
7console.log(obj.result);
8// expected output: true
1<!DOCTYPE html>
2<html>
3<body>
4<h2>Convert a string into a date object.</h2>
5<p id="demo"></p>
6<script>
7var text = '{"name":"John", "birth":"1986-12-14", "city":"New York"}';
8var obj = JSON.parse(text);
9obj.birth = new Date(obj.birth);
10document.getElementById("demo").innerHTML = obj.name + ", " + obj.birth;
11</script>
12</body>
13</html>
14
1var jsonPerson = '{"first_name":"billy", "age":23}';
2var personObject = JSON.parse(jsonPerson); //parse json string into JS object