在JSON对象的子级中添加数据。
代码示例:
let myObj = {
"name": "John",
"age": 30,
"address": {
"city": "New York",
"state": "NY",
"country": "USA"
}
};
// 添加新数据到myObj对象的address子级中
myObj.address.zipcode = 10001;
console.log(myObj);
输出结果:
{
"name": "John",
"age": 30,
"address": {
"city": "New York",
"state": "NY",
"country": "USA",
"zipcode": 10001
}
}