I have a single-line JSON file I'm trying to iterate over and looking for the best way to loop through it.
Exploded out, it looks something like:
{
"system": "Test",
"Continents": [
{
"Continent": {
"name": "Europe",
"location": "North"
},
"Continent": {
"name": "Australia",
"location": "South"
},
"Continent": {
"name": "Asia",
"location": "North"
}
}
]
}
To start, I'm loading in the JSON with the following, which successfully loads the full JSON.
File.open(json_file, 'r') do |file|
file.each do |line|
JSON.parse(line).each do |item|
## CODE TO ITERATE HERE
end
end
end
What I'm not sure how to do is to loop through the Continents
section and pull the associated records. The goal would be to loop through and output the info in a list/table/display.
Thanks for the help - let me know if I can clarify at all.