gpt4 book ai didi

javascript - 另一个数组中的数组

转载 作者:行者123 更新时间:2023-11-29 18:02:17 27 4
gpt4 key购买 nike

问题陈述

我正在尝试用这个数组中的另一个数组创建一个数组,但它对我不起作用。

这是我写的:

var arr = '{"project":['
+ '{"id":"01","name":"project1","activity":['
+ '{"num":"001","time":"7","desc":"desc","stam":['
+ ' "pre":"005","pre2":"002"]}'
+ '{"num":"002","time":"6","desc":"desc"}'
+ '{"num":"003","time":"5","desc":"desc"}'
+ '{"num":"004","time":"4","desc":"desc"}'
+ '{"num":"005","time":"3","desc":"desc"}]}]}';

最佳答案

您的 JSON 看起来已损坏。您可以使用多个在线编辑器和验证器来验证 JSON 字符串。 editorvalidator就像许多其他人的例子一样。你也可以看看here .

  • , 数组元素之间缺失
  • stam 属性看起来更像是一个对象而不是数组

它应该是这样的:

{"project":[
{"id":"01","name":"project1","activity":
[
{"num":"001","time":"7","desc":"desc","stam":{
"pre":"005",
"pre2":"002"
}
},
{"num":"002","time":"6","desc":"desc"},
{"num":"003","time":"5","desc":"desc"},
{"num":"004","time":"4","desc":"desc"},
{"num":"005","time":"3","desc":"desc"}
]
}
]
}

关于javascript - 另一个数组中的数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34041351/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com