【发布时间】:2016-01-05 03:51:12
【问题描述】:
有人可以解释为什么会这样吗?
var test = JSON
var date = '10-7'
test['id'] = []
test['id'][date] = [[1,2,3]]
test['id'][date].push([1,1,1])
console.log(test) // Output: { id: [ '10-7': [ [Object], [Object] ] ] }
console.log(JSON.stringify(test)) // Output: {"id":[]}
console.log(test['id'][date][0][0]) // Output: 1
在我将 JSON 保存到文件时(我使用 jsonfile 模块),在 stringily 中发生的情况也是如此。为什么它没有像我想要的那样打印出我的 JSON?
【问题讨论】:
标签: javascript json stringify