ruby - Hash to array conversion -
the following response returned external api , assigned ret_val
:
{:val1=>"add", :val2=>"delete", :val3=>"update"} {:val1=>"add_name", :val2=>"delete_name", :val3=>"update_name"} {:val1=>"add_city", :val2=>"delete_city", :val3=>"city"}
i want convert ret_val
array values assigned val1
, val2
, , val3
can extracted giving val1
, val2
, , val3
.so see key , value pair of comma separated pairs . expected output :
val1 : add val2 : delete val3:update
till last row returned api. please suggest. note: api return response in above format duplicate key.
below code snippet give desire result:
#ret_val=calling api ret_val.each { |x| x.each { |val| puts "#{val[0]} :#{val[1]}" } }
Comments
Post a Comment