Answers for "como ler um arquivo json com javascript"

0

como ler um arquivo json com javascript

const { read } = require('fs')
const readJsonFile = file => {
  if (file.split('.')[file.split('.').length - 1] !== 'json') return {}

  const fileContent = read(file)

  if (!fileContent) return {}

  return JSON.parse(fileContent)
}
readJsonFile('package.json')
Posted by: Guest on July-04-2020

Code answers related to "como ler um arquivo json com javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language