我的阵列:
state = [
[ "depth":0,
"id":1,
"desc":"something",
"prof": [
["ID":1, "ID_ZASOB":1],
["ID":5, "ID_ZASOB":4]
]
],
[ "depth":2,
"id":3,
"desc":"somethingOther",
"prof": [
["ID":2, "ID_ZASOB":5],
["ID":2, "ID_ZASOB":1]
]
],
]
我必须将它存储在localstorage中。
我尝试过json.stringify,但这不是一个对象,它是一个数组,
答案 0 :(得分:2)
这是一种编写数组的错误方法。您正在将数组与对象混合 数组不能有键
state = [
{ "depth":0,
"id":1,
"desc":"something",
"prof": [
{"ID":1, "ID_ZASOB":1},
{"ID":5, "ID_ZASOB":4}
]
},
{ "depth":2,
"id":3,
"desc":"somethingOther",
"prof": [
{"ID":2, "ID_ZASOB":5},
{"ID":2, "ID_ZASOB":1}
]
}
]
现在你可以将其字符串化