Skip to content

Instantly share code, notes, and snippets.

@robnyman
Created February 21, 2012 08:14
Show Gist options
  • Save robnyman/1875070 to your computer and use it in GitHub Desktop.
Save robnyman/1875070 to your computer and use it in GitHub Desktop.
JSON and localStorage
var cast = {
"Adm. Adama" : "Edward James Olmos",
"President Roslin" : "Mary McDonnell",
"Captain Adama" : "Jamie Bamber",
"Gaius Baltar" : "James Callis",
"Number Six" : "Tricia Helfer",
"Kara Thrace" : " Katee Sackhoff"
};
// Stores the JavaScript object as a string
localStorage.setItem("cast", JSON.stringify(cast));
// Parses the saved string into a JavaScript object again
JSON.parse(localStorage.getItem("cast"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment