Am 23.09.2012 23:53, schrieb Ferdous ara:
> puts data      =:::::::::::
> {"BD51-5":276611,"TOTAL":1459071,"BD51-10":1182460}
> result = JSON.parse(data)
> puts result =:::::::::::::: BD51-101182460TOTAL1459071BD51-5276611
>
> Basically,
>
> I want to see, if the output of "result" or "data"  has BD51-5   or not
> . ( or the search could be, if BD51-11 is there or not )
>

in case you do not know beforehand which exact key to look for,
you could first extract all keys with Hash#keys and then
select from the resulting array of keys those that match:

1.9.3p194 :001 > data = {'BD51-5' => 611, 'TOTAL' => 1459071, 'BD51-10' 
=> 1182460}
  => {"BD51-5"=>611, "TOTAL"=>1459071, "BD51-10"=>1182460}
1.9.3p194 :002 > hosts = data.keys.select {|key| key =~ /BD/ }
  => ["BD51-5", "BD51-10"]


-- 
<https://github.com/stomar/>