is there a require for json in node.js
JSON files don’t require an explicit exports statement. You don't need to export to use it as Javascript files.
So, you can use just require
for valid JSON document.
data.json
{
"name": "Freddie Mercury"
}
main.js
var obj = require('data.json');
console.log(obj.name);
//Freddie Mercury
As of node v0.5.x yes you can require your JSON just as you would require a js file.
var someObject = require('./somefile.json')
In ES6:
import someObject from ('./somefile.json')