Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. const readline = require('readline');
  2.  
  3. const rl = readline.createInterface({
  4. input:process.stdin,
  5. output:process.stdout
  6. });
  7.  
  8. console.log("What is your name?");
  9.  
  10. rl.on('line', (answer) => {
  11. console.log('Hi, ', answer);
  12.  
  13. rl.close();
  14. });
  15.  
  16. // var fs = require('fs');
  17. // var obj = JSON.parse(fs.readFileSync('file', 'utf8'));
  18.  
  19. var fs = require('fs');
  20. var obj;
  21.  
  22. // Read the contents of the file into memory.
  23. fs.readFile('dictionary.json', function (err, logData) {
  24.  
  25. if (err) throw err;
  26.  
  27.  
  28. // logData is a Buffer, convert to string.
  29. var text = logData.toString();
  30.  
  31. var results = {};
  32.  
  33. // Break up the file into lines.
  34. var lines = text.split('\n');
  35.  
  36. lines.forEach(function(line) {
  37. // console.log(line);
  38. var parsedJSON = JSON.parse(line);
  39. console.log(parsedJSON);
  40.  
  41. });
  42.  
  43. console.log(results);
  44. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement