Storing JSON object in HTML5 Local Storage : Stringify


This tutorial will help you to store JSON Object in LocalStorage.

This method uses a function called stringify.

Suppose we have a JSON object like this :

var data = {name:’subin’,class:’8A’};

If we want to store this JSON object in Local Storage then use the function below:

localStorage[‘info‘]=JSON.stringify(data);

That’s it. JSON Object is now stored in your Local Storage.