title: How to remove special characters before JSON.parse() while file reading
body: <p>i have a <code>json</code> within a folder that comes from <strong>third party</strong> i don't have control on <code>json</code> data just i need to <code>parse</code> it and manipulate.</p>
  
  <p><strong>some time i will get this error:</strong></p>
  
  <blockquote>
    <p>Uncaught SyntaxError: Unexpected end of JSON input
        at JSON.parse</p>
  </blockquote>
  
  <p>json is valid json but due to some special character i get above error:</p>
  
  <blockquote>
    <p>R:\30-09-18\LTP\p</p>
  </blockquote>
  
  <p><strong>some time i will get parse error:</strong></p>
  
  <blockquote>
    <p>unable to parse .........</p>
  </blockquote>
  
  <p><strong>Question:</strong> how can i remove all special characters so that <code>JSON.parse(data);</code> will not throw any <code>error</code></p>
  
  <p><strong>here is what i'm trying:</strong></p>
  
  <pre><code>var fs = require('fs');
  var path = require('path');
  var fileLoc = path.join(__dirname,'file.json');
  var content = fs.readFileSync(fileLoc,'utf8');
  content = JSON.parse(filecontent);  // error occurs here
  </code></pre>
  
  <p>please help me thanks in advance!!!</p>