Seeking
Similar to js
How to writemsg = eval('(' msg ')');
Currently we know that php uses json_decode() for string json and returns null, and Baidu has no other methods
曾经蜡笔没有小新2017-06-30 09:58:25
<?php
$json = '{"a":1,"b":2,"c":3,"d":4,"e":5}';
var_dump(json_decode($json));
var_dump(json_decode($json, true));
?>
The results are
object(stdClass)#1 (5) {
["a"] => int(1)
["b"] => int(2)
["c"] => int(3)
["d"] => int(4)
["e"] => int(5)
}
array(5) {
["a"] => int(1)
["b"] => int(2)
["c"] => int(3)
["d"] => int(4)
["e"] => int(5)
}
If you return null after json_decode, have you written the string like this"{ 'bar': 'baz' }"
, this can be parsed into JSON normally in JS, but it must be written as ' in PHP { "bar": "baz" }'
, attributes and values must be in double quotes
世界只因有你2017-06-30 09:58:25
Use json_decode(), the premise is that the json format attributes and values must use double quotes. If you use python, you don’t need to use double quotes