我有一个JSON文件如下:
[{"PROV_32_ID":1.0,"Pname":"Kabul","Time":9107,"value":24.0,"Children59m":0.0},
{"PROV_32_ID":1.0,"Pname":"Kabul","Time":9110,"value":92.0,"Children59m":8.0},
{"PROV_32_ID":1.0,"Pname":"Kabul","Time":9111,"value":78.0,"Children59m":4.0}]
我想创建另一个只有三列的JSON,如下面的JSON对象。
[{"Pname":"Kabul","Time":9107,"value":24.0},
{"Pname":"Kabul","Time":9110,"value":92.0},
{"Pname":"Kabul","Time":9111,"value":78.0}]
任何人,请帮忙。
答案 0 :(得分:0)
您可以使用for循环
<强>已更新强>
var json = [{"PROV_32_ID":1.0,"Pname":"Kabul","Time":9107,"value":24.0,"Children59m":0.0},{"PROV_32_ID":1.0,"Pname":"Kabul","Time":9110,"value":92.0,"Children59m":8.0},{"PROV_32_ID":1.0,"Pname":"Kabul","Time":9111,"value":78.0,"Children59m":4.0}]
for(var i in json)
{
delete json[i]['PROV_32_ID'];
json[i]['value'] = json[i]['Children59m'];
delete json[i]['Children59m'];
}
console.log(json)
&#13;