天天看点

PHP json_decode object时报错Cannot use object of type stdClass as array

PHP json_decode object时报错Cannot use object of type stdClass as array php再调用json_decode从字符串对象生成json对象时,如果使用[]操作符取数据,会得到上面的错误 解决方法(2种): 1、使用 json_decode($data, true)。就是使json_decode 的第二个变量设置为 true。 2、json_decode($res) 返回的是一个对象, 不可以使用 $res['key'] 进行访问, 换成 $res->key 就可以了。

PHP json_decode object时报错Cannot use object of type stdClass as array

php再调用json_decode从字符串对象生成json对象时,如果使用[]操作符取数据,会得到下面的错误

错误:

Cannot use object of type stdClass as array

大自然,飘然的风,QQ群: python技术交流群:453879716,人工智能深度学习群:251088643

golang技术交流群:316397059,vuejs技术交流群:458915921