好了,我有这样的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 :(
}
}
但是...这是不正常! 分配后,从萤火虫看到的sessionStorage看起来是这样的:
sessionStorage的 :
- ListaPermessi = “[对象的对象],[对象的对象],[对象的对象],[对象的对象],[对象的对象]”
什么是对象的数组分配给从javascript中的sessionStorage的变量的正确方法?