var details = {author:"isaac","description":"fresheggs","rating":100}; storage.setItem("details",JSON.stringify(details)); details = JSON.parse(storage.getItem("details"));
若是要存儲的鍵值是一個對象,能夠直接調用JSON.stringify()將其轉爲字符串再存儲。讀取出來後調用JSON.parse()將字符串轉爲json格式。html
詳情見原文地址:http://www.cnblogs.com/xiaowei0705/archive/2011/04/19/2021372.htmljson