js 中 如何向json 添加新元素?

2024-11-15 18:36:54
推荐回答(1个)
回答(1):

var json = {}
var i = 'name'
json[i] = '111' // json = {name:111}
json[i] = {}
json[i][i] = 111 // json = {name: {name: 111}}
console.log(json)