mercredi 14 février 2018

how to check if certain key exists in array of object json ruby on rails

how to check if a particular key exists or not in my json which is an array of objects in my controller this is my json

[{"question"=>"0a2a3452", "answer"=>"bull"}, {"question"=>"58deacf9", "answer"=>"bullafolo"}, {"question"=>"32c53e5f", "answer"=>"curosit"}, {"question"=>"b5546bcf", "answer"=>""}, {"question"=>"0f0b314", "answer"=>""}]

I tried looping through the json array, but this is tedious, as I need to check that if that json has that particular key in "if" condition

Thank you in advance any help would be highly appreciated

Aucun commentaire:

Enregistrer un commentaire