I have a JSON array structured like this:
{"data":[{"Chris":[{"long":10,"lat":19}]},{"Scott":[{"long":9,"lat":18}]}]}
I am then reading from the array in ruby, and I have started to iterate through the JSON array like so:
objArray = JSON.parse(File.open('public/test.json').read);
sections = objArray["data"]
sections.each do |subsections|
subsections.each do |supersub|
supersub.each do |obj|
#Check if variable Usrname is equal to a name in the JSON array
end
end
end
As the comment in the loop says, I need to compare the variable Usrname to the names in the JSON array i.e "Chris" and "Scott" to see if Usrname matches any of them. How is this done?