Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const readline = require('readline');
- const rl = readline.createInterface({
- input:process.stdin,
- output:process.stdout
- });
- console.log("What is your name?");
- rl.on('line', (answer) => {
- console.log('Hi, ', answer);
- rl.close();
- });
- // var fs = require('fs');
- // var obj = JSON.parse(fs.readFileSync('file', 'utf8'));
- var fs = require('fs');
- var obj;
- // Read the contents of the file into memory.
- fs.readFile('dictionary.json', function (err, logData) {
- if (err) throw err;
- // logData is a Buffer, convert to string.
- var text = logData.toString();
- var results = {};
- // Break up the file into lines.
- var lines = text.split('\n');
- lines.forEach(function(line) {
- // console.log(line);
- var parsedJSON = JSON.parse(line);
- console.log(parsedJSON);
- });
- console.log(results);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement