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格式。
详情见原文地址:http://www.cnblogs.com/xiaowei0705/archive/2011/04/19/2021372.html