1

Ripe からこの JSON 出力を取得しました。

[
  {"name"=>"organisation", "value"=>"ORG-MI1-RIPE"},
  {"name"=>"org-name", "value"=>"Mira Internetsolutions ApS"},
  {"name"=>"org-type", "value"=>"LIR"},
  {"name"=>"address", "value"=>"Mira Internetsolutions ApS Nybovej 19 DK-7500 Holstebro Denmark"},
  {"name"=>"phone", "value"=>"+45 9610 1510"},
  {"name"=>"fax-no", "value"=>"+45 9610 1511"},
  {"name"=>"admin-c", "value"=>"MIA3-RIPE", "referenced-type"=>"person-role", "link"=>{"xlink:type"=>"locator", "xlink:href"=>"http://apps.db.ripe.net/whois/lookup/ripe/person-role/MIA3-RIPE"}},
  {"name"=>"admin-c", "value"=>"MIA3-RIPE", "referenced-type"=>"person-role", "link"=>{"xlink:type"=>"locator", "xlink:href"=>"http://apps.db.ripe.net/whois/lookup/ripe/person-role/MIA3-RIPE"}},
  {"name"=>"mnt-ref", "value"=>"rh-mira", "referenced-type"=>"mntner", "link"=>{"xlink:type"=>"locator", "xlink:href"=>"http://apps.db.ripe.net/whois/lookup/ripe/mntner/rh-mira"}},
  {"name"=>"mnt-ref", "value"=>"RIPE-NCC-HM-MNT", "referenced-type"=>"mntner", "link"=>{"xlink:type"=>"locator", "xlink:href"=>"http://apps.db.ripe.net/whois/lookup/ripe/mntner/RIPE-NCC-HM-MNT"}},
  {"name"=>"mnt-by", "value"=>"RIPE-NCC-HM-MNT", "referenced-type"=>"mntner", "link"=>{"xlink:type"=>"locator", "xlink:href"=>"http://apps.db.ripe.net/whois/lookup/ripe/mntner/RIPE-NCC-HM-MNT"}},
  {"name"=>"source", "value"=>"RIPE", "comment"=>"Filtered"}
]

毎回同じ順番であるとは限りません。確認する IP は約 200.000 あります。検索方法:

"name" => "address" 

そして取得します:

"value" => "Mira Internetsolutions ApS Nybovej 19 DK-7500 Holstebro Denmark"
4

1 に答える 1

6

ArrayおよびEnumerableメソッドを使用します。この場合、以下を見つけます

data.find { |datum| datum['name'] == 'address' }
# > {"name"=>"address", "value"=>"Mira Internetsolutions ApS Nybovej 19 DK-7500 Holstebro Denmark"}
于 2012-10-01T07:33:46.460 に答える