我尝试解析JSON响应。
@response = ActiveSupport::JSON.decode(@data.body)
@应答:
{"response"=>[{"name"=>"Den", "other"=>[{"sex"=>"male"}]}]}
如何访问
@response['response']['name']
和
@response['response']['name']['sex']
答案 0 :(得分:8)
@response['response'][0]['name']
和
@response['response'][0]['other'][0]['sex']