一条js的json数据:
$s = '[{"param_name":"email","param_caption":"\u90ae\u7bb1","operator":"\u5305\u542b","value":"aaaa\u5927\u592b\u6492"}]';
方法一:
json_encode($log['result_data'],JSON_UNESCAPED_UNICODE);
方法二:
/**
* 把unicode编码的字符串转为人眼可看的字符串
* @param $unicode_str
*
* @return string
*/
function unicodeDecode($unicode_str){
$unicode_str = str_replace('"', '\"', $unicode_str);
$unicode_str = str_replace("'", "\'", $unicode_str);
$json = '{"str":"'.$unicode_str.'"}';
$arr = json_decode($json,true);
if(empty($arr)){
return '';
}
return $arr['str'];
}
返回:
[{"param_name":"email","param_caption":"邮箱","operator":"包含","value":"aaaa大夫撒"}]