A Few Tips and Tricks Here
w3 Stringify | ** w3 Try It ** | Tab Nine Stringify | Online JS Stringifyvar profile = {
name: 'John',
age: 25,
isAdmin: false,
courses: ['html', 'css', 'js']
};
var person = JSON.stringify(profile);
const obj = {name: "John", age: 30, city: "New York"};
const myJSON = JSON.stringify(obj);
from p5js
Storing Data
// Storing data:
const myObj = {name: "John", age: 31, city: "New York"};
const myJSON = JSON.stringify(myObj);
localStorage.setItem("testJSON", myJSON);
// Retrieving data:
let text = localStorage.getItem("testJSON");
let obj = JSON.parse(text);
document.getElementById("demo").innerHTML = obj.name;
const obj = {name: "John", age: 30, city: "New York"};
const myJSON = JSON.stringify(obj);
Stringify Array
Stringify a JavaScript Array It is also possible to stringify JavaScript arrays:
const arr = ["John", "Peter", "Sally", "Jane"];
Use the JavaScript function JSON.stringify() to convert it into a string.
const myJSON = JSON.stringify(arr);
Sunday November 14 2021 0950 AM