You
can use ‘require’ function to load the json file data.
For
example,
employee.json
{ "org": [{ "name": "Honeywell", "yrsOfExperience": 2.2 }, { "name": "IBM", "yrsOfExperience": 1.8 }], "firstName": "Krishna", "lastName": "Hari", "salary": 28000.0 }
HelloWorld.json
var data = require('./employee.json'); console.log(data);
Run
HelloWorld.json, you can see below messages in console.
{
org:
[ { name: 'Honeywell', yrsOfExperience: 2.2
},
{ name: 'IBM', yrsOfExperience: 1.8 } ],
firstName: 'Krishna',
lastName: 'Hari',
salary: 28000 }
No comments:
Post a Comment