Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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')
Comment

PREVIOUS NEXT
Code Example
Javascript :: discord.js on ready 
Javascript :: Auto scroll to bottom of div angular 
Javascript :: nodejs mysql insert object query 
Javascript :: use onchange with react select 
Javascript :: react native text get number of lines 
Javascript :: call laravel route js 
Javascript :: how to change attribute link in javascript 
Javascript :: js input type range on hover 
Javascript :: remove duplicates from array 
Javascript :: tailwind hover dont work 
Javascript :: jquery if .val is blank 
Javascript :: js get type of variable 
Javascript :: convert elements to array javascript 
Javascript :: dynamic select option dropdown in jquery 
Javascript :: currency convertor api in javascript 
Javascript :: how to get id of current element clicked 
Javascript :: activeclassname in react router v6 
Javascript :: how can i validate a password without regex in js 
Javascript :: how to stop browser back js 
Javascript :: wait for ajax to finish 
Javascript :: how to take input in javascript in coding 
Javascript :: Deep copy objects js JSON methods 
Javascript :: access variable outside for loop javascript 
Javascript :: javascript on keypu 
Javascript :: post data from api using jquery ajax 
Javascript :: lwc quick action close 
Javascript :: if datatable is null js 
Javascript :: get value of choice dropdown in js 
Javascript :: expo react native 
Javascript :: jquery replace html 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =