Sync:
var fs = require('fs');
var obj = JSON.parse(fs.readFileSync('file', 'utf8'));
Async:
var fs = require('fs');
var obj;
fs.readFile('file', 'utf8', function (err, data) {
if (err) throw err;
obj = JSON.parse(data);
});
More Related Contents:
- how to get POJO object in javascript from a JSON?
- How can I print a circular structure in a JSON-like format?
- “SyntaxError: Unexpected token < in JSON at position 0"
- Is it not possible to stringify an Error using JSON.stringify?
- How to parse JSON using Node.js? [closed]
- Unexpected token colon JSON after jQuery.ajax#get
- Parse large JSON file in Nodejs
- Write / add data in JSON file using Node.js
- Calling a JSON API with Node.js
- How to convert CSV to JSON in Node.js
- Parse XLSX with Node and create json
- Encrypt string in PHP and decrypt in Node.js
- Re-associating an object with its class after deserialization in Node.js
- node.js TypeError: path must be absolute or specify root to res.sendFile [failed to parse JSON]
- Combine json arrays by key, javascript
- Why is JSON.stringify not serializing prototype values?
- Typescript compiler error when importing json file
- TypeError: Converting circular structure to JSON in nodejs
- Is there a limit on the size of a string in JSON with Node.js?
- Unable to send numbers using res.send() using express with node
- Using JSON.stringify on custom class
- Cannot create a string longer than 0x1fffffe8 characters in JSON.parse?
- Javascript search inside a JSON object
- How to convert binary string to decimal?
- Secure distribution of NodeJS applications
- Set value of input instead of sendKeys() – Selenium WebDriver nodejs
- How to handle errors from setTimeout in JavaScript?
- Chrome and IE sorts JSON Object automatically, how to disable this?
- Mongoose Not Creating Indexes
- Await an iterative function without delimiter in JS