Answers for "require a json as a string"

0

require a json as a string

var fs = require('fs');

fs.readFile('/path/to/file.json', 'utf8', function (err, data) {
    if (err) throw err; // we'll not consider error handling for now
    var obj = JSON.parse(data);
});
Posted by: Guest on February-11-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language