Created
March 19, 2011 18:02
-
-
Save jookyboi/877669 to your computer and use it in GitHub Desktop.
Functions to save and load JSON in localStorage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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