如何将多维pseudoArray保存到本地存储



我的数组:

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]
    ] 
],
]

我必须把它存储在本地存储器中。

我试过json.stringfy,但这不是一个对象,而是一个数组,

这是一种不正确的数组写入方式。您正在将数组与对象混合数组不能有密钥

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}
    ] 
}
]

现在您可以将其字符串化为

相关内容

  • 没有找到相关文章