Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/rest/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 访问json密钥时出错_Php_Json - Fatal编程技术网

Php 访问json密钥时出错

Php 访问json密钥时出错,php,json,Php,Json,我有以下json数据 Merchant_stripe_response Object ( [_response:protected] => stdClass Object ( [object] => customer [created] => 1387883058 [id] => cus_3BFTkHufSbD1I9 [livemode] =>

我有以下json数据

Merchant_stripe_response Object
(
    [_response:protected] => stdClass Object
        (
            [object] => customer
            [created] => 1387883058
            [id] => cus_3BFTkHufSbD1I9
            [livemode] => 
            [description] => Order #22
            [email] => 
            [delinquent] => 
            [metadata] => stdClass Object
                (
                )

            [subscription] => 
            [discount] =>
我正在尝试获取密钥描述中的值。我试过这么做

echo $_response->description
但我犯了个错误

Fatal error: Cannot access protected property Merchant_stripe_response::$_response in C:\wamp\ 
我还尝试了json_decode来使用
echo$response['description']
,但它返回了空json

我做错什么了吗?如何使用此结构访问密钥

[_response:protected]

这很可能是它受到保护的原因——因为您不应该直接访问它。是否有一个名为
getDescription()
的函数或类似的getter

或者,再一次-我不鼓励这样做,因为可能有一个原因可以解释为什么你不能,你可以扩展课程:

class Merchant_stripe_response_custom extends Merchant_stripe_response {
    public function getDescription() {
        return $this->_response->description;
    }
}

似乎没有getter(源代码),因此您必须执行上述操作,或者在源代码中将
protected
更改为
public
(或者在其中添加getter)。

“但是我遇到了一个错误”什么错误?致命错误:无法访问受保护的财产\u条带\u响应::$\u响应在C:\wamp\n中它与条带支付网关有关。。。公开受保护是否会导致严重的安全问题?