2
問題陳述陣列內的另一個陣列
我試圖創建這個數組內的另一個數組的數組,但它並沒有爲我工作。
這是我寫的:
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"}]}]}';
這可能是有用的,我是新來的js所以不知道是否有任何幫助其http://stackoverflow.com/questions/9871634/javascript-array-inside-array-how-can- i-call-child-array-name –
不要試圖通過將字符串砸在一起來構建JSON。調試太痛苦了。使用真正的數組和真實的對象,一旦你完成,使用'JSON.stringify'。 – Quentin
也就是說,如果您將得到的字符串粘貼到http://jsonlint.com/(投票關閉,因爲問題是由簡單的印刷錯誤導致的),就會顯示您的小錯別字。 – Quentin