showing results for - "como ler um arquivo json com javascript"
Eudora
18 Jan 2019
1const { read } = require('fs')
2const readJsonFile = file => {
3  if (file.split('.')[file.split('.').length - 1] !== 'json') return {}
4
5  const fileContent = read(file)
6
7  if (!fileContent) return {}
8
9  return JSON.parse(fileContent)
10}
11readJsonFile('package.json')