Skip to content

Instantly share code, notes, and snippets.

@hattmarris
Last active August 29, 2015 14:27
Show Gist options
  • Save hattmarris/df3da0f62026df351c2b to your computer and use it in GitHub Desktop.
Save hattmarris/df3da0f62026df351c2b to your computer and use it in GitHub Desktop.
Local Storage example
// example data
var calls = {
matt: {
number: "8587645224",
id: "call-id-hash",
timestamp: "08-10-2015"
},
mark: {
number: "8587645232",
id: "call-id-hash",
timestamp: "08-10-2015"
}
};
// append corey's data
calls.corey = {
number: "8587645220",
id: "call-id-hash",
timestamp: "08-10-2015"
}
// serialize and save to window.localStorage
var str = JSON.stringify(calls); // object to string
localStorage.setItem("calls", str); // set string to local storage
// get from localStorage and decode
var out = localStorage.getItem("calls");
var obj = JSON.parse(out);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment