2013-04-14 52 views
3

我尝试解析JSON响应。Rails解析JSON来散列

@response = ActiveSupport::JSON.decode(@data.body) 

@应答:

{"response"=>[{"name"=>"Den", "other"=>[{"sex"=>"male"}]}]} 

如何访问

@response['response']['name'] 

@response['response']['name']['sex'] 

回答

8
@response['response'][0]['name'] 

@response['response'][0]['other'][0]['sex']