import json file javascript
const fs = require('fs');
const path = require('path');
let student = {
name: 'Mike',
age: 23,
gender: 'Male',
department: 'English',
car: 'Honda'
};
fs.writeFileSync(path.resolve(__dirname, 'student.json'), JSON.stringify(student));
// if you're using node.js, you can use require(.json):
// in list.json:
[{"name":"John","age":"17"},{"name":"Jack","age":"36"},{"name":"Rick","age":"76"}]
//in js
const list = require( 'list.json' );
console.log(list);
// output:
// 0: Name: "John", Age: "17"
// 1: Name: "Jack", Age: "36"
// 2: Name: "Rick", Age: "76"
Also in JavaScript:
- how to run method in method vue js on load
- javascript scroll to bottom of div
- nextjs starter template with auth
- get first element of array javascript
- javascript fastest loop
- jquery bind function to multiple events
- javascript moment get current date
- refresh page on button click jquery
- how to add multiple comment in react
- javascript add update query parameter to url
- require is not defined javascript
- random item from array javascript
- jquery get data attribute value
- nodejs express routing get
- summernote mentions ajax
- add firebase javascript
- disable mixed content via javascript
- how to use the match function in javascript for regex
- variables 2 python .Bartolome sintes Marco
- check if localstorage key exists js
- rounding number to x decimals javascript
- react template
- input set variable angular
- js conditional key