1// Array to JSON:
2const jsonString = JSON.stringify(yourArray);
3// JSON to Object / Array
4const yourData = JSON.parse(jsonString);
1var obj = {name: "Martin", age: 30, country: "United States"};
2
3// Converting JS object to JSON string
4var json = JSON.stringify(obj);
5
6console.log(json);
7// Prints: {"name":"Martin","age":30,"country":"United States"}
8"https://www.tutorialrepublic.com/faq/how-to-convert-js-object-to-json-string.php"
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
1const json = '{ "fruit": "pineapple", "fingers": 10 }';
2const obj = JSON.parse(json);
3console.log(obj.fruit, obj.fingers);
1var json_data = {"2013-01-21":1,"2013-01-22":7};
2var result = [];
3
4for(var i in json_data)
5 result.push([i, json_data [i]]);
6
7
8var data = new google.visualization.DataTable();
9data.addColumn('string', 'Topping');
10data.addColumn('number', 'Slices');
11data.addRows(result);
12