Skip to content

Instantly share code, notes, and snippets.

@samuelgoldenbaum
Forked from robnyman/json-localstorage.js
Created June 30, 2012 13:20
Show Gist options
  • Save samuelgoldenbaum/3023729 to your computer and use it in GitHub Desktop.
Save samuelgoldenbaum/3023729 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