📌  相关文章
📜  como ler um arquivo json com javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:33.178000             🧑  作者: Mango

代码示例1
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')