make object json code example
Example 1: node json stringify
let data = {
name: "John Smith",
age: 30,
hobbies: ["Programming", "Video Games"]
};
// {name:"John Smith",age:30,hobbies:["Programming","Video Games"]}
let miny = JSON.stringify(data);
// The 4 parameter signifys 4 spaces. You can also use "\t".
/* {
* name: "John Smith",
* age: 30,
* ...
*/
let pretty = JSON.stringify(data, null, 4);
Example 2: js create json from object
JSON.stringify(the_data);
Example 3: create a javascript json object
const student = {
name: "bob",
age: 7,
grade: 6
}