Skip to content

Instantly share code, notes, and snippets.

@bavey
Created July 23, 2013 20:32
Show Gist options
  • Save bavey/6065908 to your computer and use it in GitHub Desktop.
Save bavey/6065908 to your computer and use it in GitHub Desktop.
Stringify JSON object.
var testObject = { 'one': 1, 'two': 2, 'three': 3 };
// Put the object into storage
localStorage.setItem('testObject', JSON.stringify(testObject));
console.log(JSON.stringify(testObject));
// Retrieve the object from storage
var retrievedObject = localStorage.getItem('testObject');
console.log('retrievedObject: ', JSON.parse(retrievedObject));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment