var json = {
"workbookInformation": {
"version": "9.1",
"source-platform": "win"
},
"datasources1": {
...
},
"datasources2": {
...
}
}
我需要在workbookInformation
下添加新的键值对,例如:
var json={
"workbookInformation": {
"version": "9.1",
"source-platform": "win",
"new_key":"new_value"
},
"datasources1": {
...
},
"datasources2": {
...
}
}
json['workbookInformation']['new_key'] = 'new_value';
新增了一个新的键,将其添加到"workbookInformation"下。
json.workbookInformation['new_key'] = 'new_value'
这样做就可以了。 - Ajay Narain Mathur