Reputation: 5535
In my app I have directory server
and sub-directory x
and within this directory there is a file called x.js
(written using node.js).
In another sub-directory of server
there is a y.json
file; I want to use its content in x.js
.
It must be very easy, but nothing yet has helped me,
thanks!
Upvotes: 0
Views: 83
Reputation: 525
Just include it in your js file
var myJson = require('path_to_your_json');
// json file contains {"myValue": "resolved"}
console.log(myJson.myValue); // Prints "resolved";
Upvotes: 8