title: How to test if a string is JSON or not?
body: <p>I have a simple AJAX call, and the server will return either a JSON string with useful data or an error message string produced by the PHP function <code>mysql_error()</code>.  How can I test whether this data is a JSON string or the error message.  </p>
  
  <p>It would be nice to use a function called <code>isJSON</code> just like you can use the function <code>instanceof</code> to test if something is an Array.</p>
  
  <p>This is what I want:</p>
  
  <pre><code>if (isJSON(data)){
      //do some data stuff
  }else{
      //report the error
      alert(data);
  }
  </code></pre>