Last active
August 29, 2015 14:27
-
-
Save hattmarris/df3da0f62026df351c2b to your computer and use it in GitHub Desktop.
Local Storage example
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
// 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