【发布时间】:2019-06-06 06:39:44
【问题描述】:
我有以下 JSON 文件
var info = [{
"name" : "john",
"address" : "32 street, london",
"contact" : 123456
},{
"name" : "jeyy",
"address" : "51 street, new york",
"contact" : 987654321,
"gender" : "male"
},{
"name" : "robert",
"address" : "14th street, birmingham",
"contact" : 456123789,
"gender" : "male"
},{
"name" : "carlos",
"address" : "89th street, manchester",
"contact" : 23456
},{
"name": "johnny",
"address": "6th street, Washington",
"contact": 23456
},{
"name": "jack",
"address": "4th street, VA",
"contact": 23456,
"gender": "male"
}
];
如您所见,我在某些数组中缺少 "gender" = "male" 对象。如何将它们添加到缺少的对象中,而不是将它们添加到已经拥有的对象中。 另外我将如何获得新的更新文件。
【问题讨论】:
标签: javascript node.js json