I am trying to store an array in localStorage (HTML5) which needs to be a string, but enable direct access to objects I store in the array by defining the index. When I try to JSON.stringify I just get [] which doesn't store the array of objects in localStorage.
var mylist = [];
mylist["mykey1"] = {id: "1", title: "First"};
mylist["mykey2"] = {id: "2", title: "Second"};
localStorage.setItem("mylist", JSON.stringify(mylist)); // stores [] only - uggh!
var mylist2 = JSON.parse(localStorage.getItem("mylist"));
document.write(JSON.stringify(mylist2["mykey1"])); // want it to display: {"id": "1", "title": "First"}