title: json_decode returns string type instead of object
body: <p>I'm passing a JSON-encoded string to <code>json_decode()</code> and am expecting its output to be an object type, but am getting a string type instead.  How can I return an object?</p>
  
  <p>In the docs, the following returns an object:</p>
  
  <pre><code>$json = '{"a":1,"b":2,"c":3,"d":4,"e":5}';
  var_dump(json_decode($json));
  </code></pre>
  
  <p>However, if I <code>json_encode()</code> the string first and then call <code>json_decode()</code>, the output is a string and not an object:</p>
  
  <pre><code>$json = json_encode('{"a":1,"b":2,"c":3,"d":4,"e":5}');
  var_dump(json_decode($json));
  </code></pre>
  
  <p>This is just a simplified example. In practice what I'm doing is pushing a JSON-encoded string to PHP via AJAX.  However it does illustrate the problem of converting this encoded JSON string to an object I can read in PHP, e.g., "<code>$json-&gt;a</code>".</p>
  
  <p>How can I return an object type?</p>
  
  <p>thanks for the replies !
   The actual context for this question was am using a JSON Response from a API.
   But when I do the json_decode to this response and try to access the values like - $json=json_decode(json response from API); 
  echo $json->a 
  it gives me a error: Object of class stdClass could not be converted to string</p>