0

我有下面提到的编码。我想从这个数组中获取 response_text 和 response_code 的值。任何人都可以帮助我如何获取特定的键值。

stdClass Object
(
    [_OPS_version] => 0.9
    [protocol] => XCP
    [request_response_time] => 0.441
    [response_text] => Command completed successfully
    [is_search_completed] => 1
    [action] => REPLY
    [attributes] => stdClass Object
        (
            [suggestion] => stdClass Object
                (
                    [count] => 0
                    [response_text] => Missing tld list, supported tlds are [.com,.net,.org,.info,.biz,.us,.mobi]
                    [response_code] => 500
                    [is_success] => 0
                )

        )

    [response_code] => 200
    [is_success] => 1
)

提前致谢

4

2 回答 2

0

使用命名空间 System.Reflection,尝试使用 PropertyInfo[] info = stdClass.GetProperies(),然后遍历每个属性并在调试模式下检查值。

于 2012-11-21T06:45:53.900 回答
0

在 php 中,我们也可以获取下面提到的值

$check=$results->{'attributes'}->suggestion->response_text;

参考: http ://bytes.com/topic/php/answers/161452-stdclass-object-get_object_vars

于 2012-11-21T07:25:34.870 回答