The json string passed to PHP through AJAX is sometimes added Use backslash "" to escape. When processing with PHP, you need to remove the backslash first and then json_decode.
$str = stripslashes($_POST['json']); $arr = json_decode($str,true);
PS: How to remove the backslash in front of double quotes when grabbing json with php get
Your data in JSON format is not standard. You can replace "with" first.
Use the json_decode() system function to convert it into a json object. If you need to convert it into an array, just add the second parameter to true.
If the output is still NULL, it is due to the existence of BOM header information,
Copy code The code is as follows:
$arr = json_decode(trim($json,chr(239).chr(187).chr(191)),true);
Just convert.
The entire content of this article has been introduced. I hope it will be helpful to you in using PHP to remove backslashes in json strings and remove backslashes before double quotes.