i) create JSON - JavaScript object notation(JSON) can be defined in curly brace, & then stringify to variable.
myObj = { name: "John", age: 31, city: "New York" };
myJSON = JSON.stringify(myObj);
ii) store value to local Storage or database
localStorage.setItem("testJSON", myJSON); OR save this json to database
iii) get saved data
text = localStorage.getItem("testJSON");
obj = JSON.parse(text);
document.getElementById("hello").innerHTML = obj.name;
final code likes below,
<!DOCTYPE html>
<html>
<body>
<h2>Store and retrieve data from local storage.</h2>
<p id="hello"></p>
<script>
var myObj, myJSON, text, obj;
// Storing data:
myObj = { name: "John", age: 31, city: "New York" };
myJSON = JSON.stringify(myObj);
localStorage.setItem("testJSON", myJSON);
// Retrieving data:
text = localStorage.getItem("testJSON");
obj = JSON.parse(text);
document.getElementById("hello").innerHTML = obj.name;
</script>
</body>
</html>