[PHP]判断字符串是否是JSON

{{ time }}

代码如下

//判断是否是合法json, PHP版本大于5.3可用
function is_json($string)
{
    json_decode($string);
    return (json_last_error() == JSON_ERROR_NONE);
}