such as the front desk a JS object:
{
AA: "Cc\dd"
}
$d = ' {\ ' aa\ ": \" cc\\dd\ "} ';
This time with Json_decode ($d, true) will return NULL, if handled with Stripslashes, the slash is gone, will become AA:CCDD
How to support the decode.
Thank you.
------Answer---------
------Other answers (100 points)---------
"\ \" is parsed as "\" when it is output in the browser.
Proposed landlord in front of the "AA": "CC\DD" changed to "AA": "Cc\\dd"
This is accepted as ' {\ ' aa\ ': \ ' cc\\\\dd\ '} '
Then you might want to use a JSON class. The next code is too long to be posted.
-
PHP Code
-
<?php include (' json.class.php '), $json _str = ' {\ ' aa\ ': \ ' cc\\\\dd\ '} '; $json = new My_json (); $json _str = Stripslashes ( $json _str); Var_dump ($json->decode ($json _str));//array ' aa ' = = String ' Cc\dd ' (length=5)?>
Or the landlord can choose to pass the link encodeURI () to encode
or encode the content encodeuricomponent ()
How can I let Json_decode parse a string with a slash