title: How to throw an error message with json_decode?
body: <p>How can I throw an error message with <code>json_decode</code>?</p>
  
  <p>For instance,</p>
  
  <pre><code>$error = array(
      "key_name" =&gt; "Keyname - empty!",
      "pub_name" =&gt; "Pubname - empty!",
      "path" =&gt; "path - empty!"
  );
  
  $json = json_encode($error);
  $object = json_decode($json);
  print_r($object-&gt;keyname);
  </code></pre>
  
  <p>I get,</p>
  
  <blockquote>
    <p>Notice: Undefined property: stdClass::$key_namex in C:.... on line 32</p>
  </blockquote>
  
  <p><code>keyname</code> does not exist actually, so I wonder if I can check it with the <code>if condition</code>,</p>
  
  <pre><code>if(!$object-&gt;keyname) { .... }
  </code></pre>
  
  <p>is it possible?</p>
  
  <p>and sometimes I there are no error content,</p>
  
  <pre><code>$error = array(
  );
  
  $json = json_encode($error);
  $object = json_decode($json);
  print_r($object-&gt;key_name);
  </code></pre>
  
  <p>so I thought of throwing an error before proceeding to the codes that follows,</p>
  
  <pre><code>if($object == '') {...}
  </code></pre>
  
  <p>is it possible?</p>