title: Parse JSON string to detect error response
body: <p>i'm working with a server which response  using the JSON format.</p>
  
  <p>when the request contain valid data they respond with a string like this</p>
  
  <blockquote>
    <p>{"data":{"results":[{"Branch":"ACCT590006"}]}}</p>
  </blockquote>
  
  <p>but if the parameters of the request are incorrect the response goes like this</p>
  
  <blockquote>
    <p>{"error":{"errors":[{"domain":"global","reason":"invalid","message":"Invalid
    Params"}],"code":98865,"message":"Invalid
    param value"}}</p>
  </blockquote>
  
  <p>So the questions are how i can determine when the response of the server contains a error string using the <a href="http://docwiki.embarcadero.com/VCL/en/DBXJSON.TJSONObject" rel="nofollow"><code>TJSONObject</code></a>   object and additionally parse the JSON string to show the messages and error codes like this.</p>
  
  <pre><code>Failed reason : invalid 
  Message : Invalid params 
  Code: 98865 
  message : invalid param value.
  </code></pre>