PHP implements the json_decode method without escaping Chinese characters,
This example describes how to implement json_decode without escaping Chinese Characters in PHP. We will share this with you for your reference. The details are as follows:
By default, the json_decode method of PHP will escape special characters and convert Chinese charactersUnicodeEncoding format.
This makes it very difficult for the database to view the text. Therefore, we need to limit the escape of Chinese characters.
For PHP5.4 +, the second parameter of the json_decode function can be used to limit the escape range.
To restrict Chinese characters, useJSON_UNESCAPED_UNICODEParameters.
json_encode($a, JSON_UNESCAPED_UNICODE);
For PHP5.3, You can first convert ASCII 127 or more characters to HTML values to avoid being transcoded by the json_decode function:
function my_json_encode($arr){ //convmap since 0x80 char codes so it takes all multibyte codes (above ASCII 127). So such characters are being "hidden" from normal json_encoding array_walk_recursive($arr, function (&$item, $key) { if (is_string($item)) $item = mb_encode_numericentity($item, array (0x80, 0xffff, 0, 0xffff), 'UTF-8'); }); return mb_decode_numericentity(json_encode($arr), array (0x80, 0xffff, 0, 0xffff), 'UTF-8');}
PS: Here are some useful json online tools for your reference:
Online JSON code verification, validation, beautification, and formatting tools:
Http://tools.jb51.net/code/json
JSONOnline formatting tool:
Http://tools.jb51.net/code/jsonformat
Online XML/JSON conversion tools:
Http://tools.jb51.net/code/xmljson
JsonCode Online formatting/beautification/compression/editing/conversion tools:
Http://tools.jb51.net/code/jsoncodeformat
C language style/HTML/CSS/json code formatting and beautification tools:
Http://tools.jb51.net/code/ccode_html_css_json