title: Nodejs Convert text to JSON
body: <p>For some reason I'm having such a hard time converting this txt file to an actual javascript array.</p>
  
  <p><strong>myJson.txt</strong></p>
  
  <pre><code>{"action": "key press", "timestamp": 1523783621, "user": "neovim"}
  {"action": "unlike", "timestamp": 1523784584, "user": "r00k"}
  {"action": "touch", "timestamp": 1523784963, "user": "eevee"}
  {"action": "report as spam", "timestamp": 1523786005, "user": "moxie"}
  </code></pre>
  
  <p>Currently what I have that doesn't work</p>
  
  <pre><code>const fs = require('fs');
  
  function convert(input_file_path) {
      const file = fs.readFileSync(input_file_path, 'utf8');
      const newFormat = file
        .replace(/(\r\n\t|\n|\r\t)/gm,'')
        .replace(/}{/g, '},{');
  
      console.log([JSON.parse(newFormat)]);
  }
  
  convert('myJson.txt');
  </code></pre>