问题陈述
我试图在这个数组中创建一个包含另一个数组的数组,但它并不适合我。
这就是我写的:
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"}]}]}';
答案 0 :(得分:4)
您的JSON看起来已损坏。您可以使用多个在线编辑器和验证器来验证JSON字符串。 editor和validator仅作为mony其他人的一个例子。您也可以查看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"}
]
}
]
}
答案 1 :(得分:0)
json格式不正确:
{
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"
}
]
}]
}