[英]How to parse stdClass object in php
You can use json_encode
to convert it to a json. 您可以使用json_encode
将其转换为json。 After which you can use json_decode
with the second parameter set to true
which will return an array instead of an StdObject
. 之后,您可以将json_decode
与第二个参数设置为true
,这将返回一个数组而不是StdObject
。
If the api you're calling simply returns a json itself then you can go ahead and use json_decode
directly with the second argument set to true
to yield the same result. 如果您要调用的api本身仅返回一个json,那么您可以继续使用json_decode
并将第二个参数设置为true
来产生相同的结果。
There are other ways, but this is the simplest. 还有其他方法,但这是最简单的。
You can check out other questions, like this one or this one . 您可以检查其他问题, 例如这个或这个 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.