title: How to catch exceptions of JSON.parse()?
body: <p>The string I have to parse comes from a <code>FileReader()</code>, it may be the content of a valid json file or it may be invalid (eg a script.js) ...</p>
  
  <p>The problem is that <code>try/catch</code> doesn't seem to work with <code>JSON.parse()</code> ?</p>
  
  <p>The following code doesn't catch de exception <code>JSON.parse: unexpected character at line 1 column 1 of the JSON data</code> with an invalid file.</p>
  
  <pre><code>try
  {
      var json = JSON.parse( content );
      ..
  }
  catch (e)
  {
      ..
  }
  </code></pre>
  
  <p>To make a first validation I test the 1st character with <code>( content.substr(0, 1) === '{' )</code> but I suppose it's insufficient.</p>
  
  <p>What is the best way to achieve this ? </p>
  
  <p>EDIT: This question was asked by mistake.</p>