[英]How to read JSON object in PHP?
I want to read status and message object of this JSON.我想读取此 JSON 的状态和消息对象。
I have tried json_decode()
but its not working fine.我试过
json_decode()
但它不能正常工作。
JSON: JSON:
{"d":"{\"successMessage\":\"24 rows added / updated\",\"failMessage\":null,\"status\":true}"}
please use the following code请使用以下代码
$json = '{"d":"{\"successMessage\":\"24 rows added / updated\",\"failMessage\":null,\"status\":true}"}';
echo "<pre>";
$myArr = json_decode($json, true);
$varArr = json_decode($myArr["d"]);
print_r($varArr)."<hr>";
echo $varArr->successMessage;
and it will give output as它将输出为
stdClass Object
(
[successMessage] => 24 rows added / updated
[failMessage] =>
[status] => 1
)
24 rows added / updated
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.