如何清洗,并通过编辑的NodeJS JSON文件
我有一个包含一些数据,我需要删除JSON文件:
{
"Count": 2,
"Items": [
{
"character": {
"S": "1234"
},
"location": {
"S": "east"
},
"inputs": {
"S": "1"
},
"region": {
"S": "north"
},
"access": {
"S": "0"
} "S": "physical"
}
],
"ScannedCount": 2,
"ConsumedCapacity": null
}
我想删除从项目的[]括号外的一切
回答如下:我发现这个工作。谢谢@ Zero298了最初的想法。
var fs = require('fs');
var newJSON = '';
newJSON = JSON.stringify(JSON.parse(fs.readFileSync('my_file.json', 'utf8'))['Items'], null, 4);
console.log("THIS IS THE NEW JSON");
console.log(newJSON);