fork(7) download
  1. <?php
  2.  
  3. function isValidJSON($str) {
  4. json_decode($str);
  5. return json_last_error() == JSON_ERROR_NONE;
  6. }
  7.  
  8. var_dump(isValidJSON(null));
  9. var_dump(isValidJSON(""));
Success #stdin #stdout 0.01s 52488KB
stdin
Standard input is empty
stdout
bool(true)
bool(true)