def _parse_json(self, resources, exactly_one=True):
        """
        Parse type, words, latitude, and longitude and language from a
        JSON response.
        """

        code = resources['status'].get('code')

        if code:
            # https://docs.what3words.com/api/v2/#errors
            exc_msg = "Error returned by What3Words: %s" % resources['status']['message']
            if code == 401:
                raise exc.GeocoderAuthenticationFailure(exc_msg)

            raise exc.GeocoderQueryError(exc_msg)

        def parse_resource(resource):
            """
            Parse record.
            """

            if 'geometry' in resource:
                words = resource['words']
                position = resource['geometry']
                latitude, longitude = position['lat'], position['lng']
                if latitude and longitude:
                    latitude = float(latitude)
                    longitude = float(longitude)

                return Location(words, (latitude, longitude), resource)
            else:
                raise exc.GeocoderParseError('Error parsing result.')

        location = parse_resource(resources)
        if exactly_one:
            return location
        else:
            return [location]
def _parse_json ( self , resources , exactly_one = True ) : code = resources [ 'status' ] . get ( 'code' ) if code : exc_msg = "Error returned by What3Words: %s" % resources [ 'status' ] [ 'message' ] if code == 401 : raise exc . GeocoderAuthenticationFailure ( exc_msg ) raise exc . GeocoderQueryError ( exc_msg ) def parse_resource ( resource ) : if 'geometry' in resource : words = resource [ 'words' ] position = resource [ 'geometry' ] latitude , longitude = position [ 'lat' ] , position [ 'lng' ] if latitude and longitude : latitude = float ( latitude ) longitude = float ( longitude ) return Location ( words , ( latitude , longitude ) , resource ) else : raise exc . GeocoderParseError ( 'Error parsing result.' ) location = parse_resource ( resources ) if exactly_one : return location else : return [ location ]
Parse type, words, latitude, and longitude and language from a
        JSON response.