Skip to content

Instantly share code, notes, and snippets.

@jookyboi
Created March 19, 2011 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jookyboi/877669 to your computer and use it in GitHub Desktop.
Save jookyboi/877669 to your computer and use it in GitHub Desktop.
Functions to save and load JSON in localStorage
// requires: https://github.com/douglascrockford/JSON-js/raw/master/json2.js
{
saveJson: function(key, json) {
localStorage[key] = JSON.stringify(json);
},
loadJson: function(key) {
var value = localStorage[key];
if (value === undefined || value === null)
return null;
return JSON.parse(value);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment