JSON遇到中文乱码问题的解决方法
解决方法:
1. 把所有的中文转为UTF-8编码(本身是utf8的话无须转)
2. 把中文的urlencode一下 $testJSON=array('name'=>'中文字符串','value'=>'test'); //echo json_encode($testJSON); foreach ( $testJSON as $key => $value ) { $testJSON[$key] = urlencode ( $value ); } 3、然后json_encode之后再urldecode一下转回来 $test_json_str = json_encode ($testJSON ) echo urldecode ($test_json_str); 查看输出结果为: {“name”:”中文字符串”,”value”:”test”} 这样可以很好的解决中文JSON乱码问题。

如有侵权请及时联系我们处理,转载请注明出处来自
随机推荐
科技快讯 |备案号:( 沪ICP备2026008940号-1 )