I was wondering if there was an efficient ("canonical") way to traverse a dictionary with a JSON like structure. For example, I have a dictionary with an array of dictionaries that sometimes don't have the same keys. I then need to iterate over these dictionaries and check if an specific key has a certain value. For example:
for cell in cells
if cell["key1"]["key2"]["key3"] == true
# do stuff
end
end
The issue is that sometimes the cell won't have either "key1", or "key2" or "key3", so a simple get(cell, key1, false) won't work. Of course, I could always write a bunch of if statements, but I was wondering if there was a smarter and more direct way of doing this.