Code below returns me all counties as a string, I can see that by using inspect method.
def self.all_counties
response['ChargeDevice'].each do |charger|
puts ['ChargeDeviceLocation']['Address']['County'].inspect
end
end
What would be the right way to store every returned string in one array so I can manipulate it later?
JSON
"ChargeDeviceLocation" => {
"Latitude" =>"51.605591",
"Longitude" =>"-0.339510",
"Address" => {
"County" =>"Greater London",
"Country" =>"gb"
}
mapinstead ofeachand store the result in a variable.Hash#diginstead of repeated[]calls, to avoidnilerrors.charger.dig('ChargeDeviceLocation', 'Address', 'County')TypeError: no implicit conversion of String into Integerexception, because there is noAddressindex on the['ChargeDeviceLocation']array.