我想解析这个 JSON:
{
"date":[
"dia_29_06_13"
],
"jsonList":{
"__type":"File",
"name":"d138af3c-4da0-4ab9-b3ff-0ac09a352fd8-lista.json",
"localName":[
"Patropi"
],
"pspReference":"8513723597141689",
"qrcode":"KWX35ERoNJ",
"status":"true",
"valor":127,
"createdAt":"2013-06-27T19:01:46.830Z",
"updatedAt":"2013-06-27T19:01:57.830Z",
"objectId":"fcXMwYaDMQ",
"ACL":{
"*":{
"write":true,
"read":true
},
"KWX35ERoNJ":{
"write":true,
"read":true
}
}
}
但它总是给我这个错误:
date: 0: => dia_29_06_13
Catchable fatal error: Object of class stdClass could not be converted to string in /home/storage/a/1c/6e/semhora/public_html/payment/temp3.php on line 42
我正在使用这段代码:
$response = curl_exec($rest);
$jsonIterator = new RecursiveIteratorIterator(
new RecursiveArrayIterator(json_decode($response)),
RecursiveIteratorIterator::SELF_FIRST);
foreach ($jsonIterator as $key => $val) {
if(is_array($val)) {
echo "$key:\n";
} else {
echo "$key: => $val";
}
}