开发者

Dealing with hash in PHP json object

开发者 https://www.devze.com 2023-01-15 08:01 出处:网络
I have a json object that follows the following structure: $foo->bar[\'1\']->#foobar The hash is causing it to fail, how do I ge开发者_如何学Pythont the value of #foobar?

I have a json object that follows the following structure:

$foo->bar['1']->#foobar

The hash is causing it to fail, how do I ge开发者_如何学Pythont the value of #foobar?

Thanks


Try the curly brace syntax:

$foo->bar['1']->{'#foobar'}


When you use PHP's json_decode, pass true as the second variable, that will return an associative array, those are easier to deal with in such cases.

0

精彩评论

暂无评论...
验证码 换一张
取 消