|
-
Jan 27th, 2010, 12:25 AM
#1
[RESOLVED] Storing array/object into localStorage?
localStorage will only store values in string format. Is there any way to modify it to store arrays/objects? http://hacks.mozilla.org/2009/06/localstorage/ says it's possible to use native JSON support to create an object store on top of localStorage, but I can't work out how to apply the given example code:
javascript Code:
Storage.prototype.setObject = function(key, value) {
this.setItem(key, JSON.stringify(value));
}
Storage.prototype.getObject = function(key) {
return JSON.parse(this.getItem(key));
}
Can anyone help me decipher this and show me how to use it to store objects in localStorage?
Last edited by tr333; Jan 27th, 2010 at 12:36 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|