观察这个小脚本:
$array = array('stuff' => 'things');
print_r($array);
//prints - Array ( [stuff] => things )
$arrayEncoded = json_encode($array);
echo $arrayEncoded . "<br />";
//prints - {"stuff":"things"}
$arrayDecoded = json_decode($arrayEncoded);
print_r($arrayDecoded);
//prints - stdClass Object ( [stuff] => things )
为什么PHP将JSON对象变成一个类?
如果不是一个数组,它是json_encoded
那么json_decoded
产生完全相同的结果?