好的,所以我有这个 JSON:
{"Status":"OK!","ListaPermessi":
[{"IdPermesso":10,"Nome":"WIND_PARAMS"},
{"IdPermesso":11,"Nome":"ADMIN_SERVER"},
{"IdPermesso":21,"Nome":"REC"},
{"IdPermesso":22,"Nome":"REC_DIST"},
{"IdPermesso":23,"Nome":"REC_DIST_CR"}
]}
我的代码是:
var parsedResult = JSON.parse(result); // where result is the above JSON
if (parsedResult.Status === "OK!") {
// Set sessionStorage vars
if (typeof(Storage) !== "undefined") {
// localStorage & sessionStorage support!
sessionStorage.setItem("ListaPermessi", parsedResult.ListaPermessi);
}
else {
// Sorry! No web storage support :(
}
}
但是......这不能正常工作!赋值后,从 Firebug 看到的 sessionStorage 是这样的:
会话存储:
- ListaPermessi = " [对象对象],[对象对象],[对象对象],[对象对象],[对象对象] "
从javascript将对象数组分配给sessionStorage变量的正确方法是什么?