When the mcrypt_decrypt function is used in PHP to process Json strings, the Json_decode returns null.
Source: Internet
Author: User
When I decode the generated json file yesterday, I suddenly found that the returned value is NUll (the json string in the json file is encrypted). after repeated tests, it is found that as long as the json contains Chinese characters and is decrypted, the decode operation returns NULL, if Han suddenly finds that the returned value is NUll when he decode the generated json file yesterday (the json string in the json file is encrypted), after repeated tests, it is found that as long as the json contains Chinese characters and is decrypted, the decode operation returns NULL. If no Chinese characters exist, the decode operation is normal. at first, I thought it was caused by encoding. after repeated tests, I still had a problem. Finally, I found the mcrypt_decrypt function in the decryption operation, check the manual and find that this function may include the hidden character \ 0 after the returned character. Is this the case? So use str_replace ("\ 0", "", $ json); the result is displayed. I wiped it and wasted half a day.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.