Skip to content

Instantly share code, notes, and snippets.

@nkgrnkgr
Created June 23, 2018 14:14
Show Gist options
  • Save nkgrnkgr/c2bfa3c1593ac2fe69c1eda91d2ccebc to your computer and use it in GitHub Desktop.
Save nkgrnkgr/c2bfa3c1593ac2fe69c1eda91d2ccebc to your computer and use it in GitHub Desktop.
Node.js で JSONファイルの読み込み / Object.entries をつかった key, value 同時取得の実装
const fs = require('fs');
const json = JSON.parse(fs.readFileSync('./a.json', 'utf8'));
for (let o of json) {
for (let [key, value] of Object.entries(o)) {
console.log({ key, value });
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment