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);
1<script>
2 // Convert JSON String to JavaScript Object
3 var JSONString = '[{"name":"Jonathan Suh","gender":"male"},{"name":"William Philbin","gender":"male"},{"name":"Allison McKinnery","gender":"female"}]';
4
5 var JSONObject = JSON.parse(JSONString);
6 console.log(JSONObject); // Dump all data of the Object in the console
7 alert(JSONObject[0]["name"]); // Access Object data
8</script>
9
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