English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The data obtained from the APP side or from other pages via post, get is usually in array form. Because array form is not easy to transmit, so it is generally converted to json before sending. I thought that the sender json_encode(), the receiver json_decode(), would solve the problem, but it was found that json_decode() is NULL.
It usually reacts that a parameter 'true' is missing, but when looking back json_decode($data, true); Then why would it still be NULL? Is it encoding, no, it's printed directly after receiving, it's in the form of a complete json string, and it can also be normally parsed on the json parsing website on the Internet.
So what's the matter? It's actually a problem of encoding translation.
The following method can achieve correct parsing.
$data = stripslashes(html_entity_decode($info)); //$info is the passed json string $data = json_decode($data, TRUE);
At this point, $data is the array after parsing!
The function of the html_entity_decode() is to convert HTML entities to characters.
The function of the stripslashes() is to remove backslashes.
This is the entire content that the editor shares with everyone about the solution to Json_decode parsing the json string to NULL (must read). I hope it can be a reference for everyone, and I also hope everyone will support the呐喊 tutorial more.