

def _parse_json(self, page, exactly_one=True):
    'Returns location, (latitude, longitude) from json feed.'
    places = page.get('results', [])
    if (not len(places)):
        self._check_status(page.get('status'))
        return None

    def parse_place(place):
        'Get the location, lat, lng from a single json place.'
        location = place.get('formatted')
        latitude = place['geometry']['lat']
        longitude = place['geometry']['lng']
        return Location(location, (latitude, longitude), place)
    if exactly_one:
        return parse_place(places[0])
    else:
        return [parse_place(place) for place in places]

dataset/ETHPy150Open geopy/geopy/geopy/geocoders/opencage.py OpenCage._parse_json/original