Hi all,
I am using httparty to get the content of a service.
@reponse = httparty.get(url)
puts @reponse.parsed_response
parsed_reponse is as follows,
@parsed_response =>{“name” => “ruby”, “number” => {“item”=>{"@no"=>“1”,
“itemcontent”=>{“itemcategory”=>{"@itemtype"=>“Book”,
“@itemtag”=>“Generak”}}, “form”=>“text”, “shape”=>“square”,
“dimension”=>“full”, “type”=>{“category”=>{"@itemid"=>“24”,
“@itemexpiry”=>“false”, “@quote”=>"[FRESH]", “$”=>“2010”}},
“expiryComments”=>{“expiryStatus”=>{"@expiry"=>“true”, “$”=>“2012”}}},
“shop”=>{“shopName”=>“STORE”}}}
I need to parse each and every hash and its elements and even array of
elements inside each hash
for example say,
I need to parse and equate,
name = “rub”
@parsed_response[“name”].should == name
this will result
expected: rub
got: ruby
similarly, for each and every hash I need to check the value with some
other value, whether they are equal or not.
Can anyone kindly explain with code, how to parse each value of the
above response.
the above parsed response is only one such record, but i do have
multiple records to check like
@parsed_response => {“name” => “ruby”, “number” => {“item”=>{"@no"=>“1”,
…}},{“item” => {"@no" = >“2”, …}},{“item” => {"@no" = >“3”,
…}}}
In this case I need to check for all the values. need assistance for
this.
Thanks in advance