1
第一次尝试使用Ruby AWS ADK V2,我试图格式化我回来的数据,并且似乎很难将其转化为可用的格式。处理来自Aws :: Route53 :: Client.new的更好响应:: Client.new
我想要做的就是获取托管区域列表并显示在表格中。
我有了一个帮手:
def hosted_zones
r53 = Aws::Route53::Client.new
#convert to hash first so we can parse and covert to json
h = (r53.list_hosted_zones).to_hash
j = JSON.parse((h.to_json))
end
然后返回我下面的JSON:
{
"hosted_zones": [{
"id": "/hostedzone/Z1HSDGASSSME",
"name": "stagephil.com.",
"caller_reference": "2016-07-12T15:33:45.277646707+01:00",
"config": {
"comment": "Private DNS zone for stage",
"private_zone": true
},
"resource_record_set_count": 10
}, {
"id": "/hostedzone/ZJDGASSS0ZN3",
"name": "stagephil.com.",
"caller_reference": "2016-07-12T15:33:41.290143511+01:00",
"config": {
"comment": "Public DNS zone for stage",
"private_zone": false
},
"resource_record_set_count": 7
}],
"is_truncated": false,
"max_items": 100
}
为了这我运行一个真的,但同时声明,在所有的hosted_zone项互动放入桌子。
这是获得回复的最佳方式还是您可以请求回复为json?