如何在早于 5.3.0 的 PHP 中验证 JSON?
2022-08-30 15:27:13
有没有办法在不使用的情况下检查变量在PHP中是否是有效的JSON字符串?我的 PHP 版本早于 5.3.0。json_last_error()
有没有办法在不使用的情况下检查变量在PHP中是否是有效的JSON字符串?我的 PHP 版本早于 5.3.0。json_last_error()
$ob = json_decode($json);
if($ob === null) {
// $ob is null because the json cannot be decoded
}
$data = json_decode($json_string);
if (is_null($data)) {
die("Something dun gone blowed up!");
}