The PHP json_decode function will return a strict null if the string passed into it is invalid json or it can’t parse it successfully. The method below can be used for testing json
$decodedJson = json_decode($json); if($decodedJson !== null) { echo('$decodedJson is valid json!'); }else{ echo('$decodedJson is invalid json'); }