1

我有哈希:

request = {"AutoCreate"=>{"Response"=>{"Status"=>"OK", "StatusCode"=>"0", "TransactionStatus"=>"SUCCEEDED", "TransactionReference"=>"MxhRNvs5EuJLTEkhKqO5Olgk2zMtYMTOI0IvQInWPV8EYsWAI7Aji09B3B8Bigzkee20e3bc4bd9eab997d7825b883b7359"}}}

如何访问 、 和 的"Status"哈希"StatusCode""TransactionStatus"

4

3 回答 3

5
result["AutoCreate"]["Response"]["Status"]
result["AutoCreate"]["Response"]["StatusCode"]
result["AutoCreate"]["Response"]["TransactionStatus"]
于 2013-11-11T14:04:30.020 回答
2

访问状态

result['AutoCreate']['Response']['Status']

访问状态码

result['AutoCreate']['Response']['StatusCode']

和交易状态

result['AutoCreate']['Response']['TransactionStatus']
于 2013-11-11T14:07:29.173 回答
1
vals_to_get = ["Status", "StatusCode", "TransactionStatus"]
p request["AutoCreate"]["Response"].values_at(*vals_to_get) #=> ["OK", "0", "SUCCEEDED"]
于 2013-11-11T14:57:42.113 回答