Php parses the json string from HTMLpost. this post is finally edited by asia_deng from 2014-07-0715: 48: 48. I converted a json object into a json string in js, put it in an implicit input and submit it to php. this is the HTML part. & lt; input & nbsp; typehidden & nbsp php parses the json string from HTML post.
This post was last edited by asia_deng at 15:48:48, January 7 ,.
In js, I convert a json object into a json string and put it in an implicit input to submit it to php.
This is the HTML part.
The string obtained in php is:
[{\\"table\\":\\"a\\",\\"field\\":\\"value\\",\\"max\\":60,\\"min\\":null}]
String Processing
$ Json_string = $ _ POST ['json'];
$ Json = htmlspecialchars_decode ($ json_string );
Print_r (json_decode ($ json); // The result is null.
Change
$ Json = stripslashes (htmlspecialchars_decode ($ json_string ));
Print_r (json_decode ($ json); // The result is still null.
Change it.
$ Json = stripslashes (htmlspecialchars_decode ($ json_string )));
Print_r (json_decode ($ json); // well, the result is still empty.
------ Solution --------------------
This post was last edited by xuzuning at 15:57:51 on
It's really hard for you to do so complicated coding.
$s = '[{\\"table\\":\\"a\\",\\"field\\":\\"value\\",\\"max\\":60,\\"min\\":null}]';
$s = html_entity_decode($s);
$s = stripslashes($s);
print_r(json_decode($s, 1));
Array
(
[0] => Array
(
[table] => a
[field] => value
[max] => 60
[min] =>
)
)
------ Solution --------------------
$str='[{\\"table\\":\\"a\\",\\"field\\":\\"value\\",\\"max\\":60,\\"min\\":null}]';
$new=htmlspecialchars_decode($str);
$new=str_replace('\\','',$new);
$new1=json_decode($new,true);
echo "";
print_r($new1);
echo "
";
Array
(
[0] => Array
(
[Table] =>
[Field] => value
[Max] => 60
[Min] =>
)
)
------ Solution --------------------
Echo base64_encode ($ _ POST ['json']);
Post result