(input_value)
Work around a JSON dict with string, not float, lat/lngs.
    Given anything (list/dict/etc) it will return that thing again, *but* any
    dict (at any level) that has only 2 elements lat & lng, will be replaced
    with the lat & lng turned into floats.
    If the API returns the lat/lng as strings, and not numbers, then this
    function will 'clean them up' to be floats.
Work around a JSON dict with string, not float, lat/lngs.
    Given anything (list/dict/etc) it will return that thing again, *but* any
    dict (at any level) that has only 2 elements lat & lng, will be replaced
    with the lat & lng turned into floats.
    If the API returns the lat/lng as strings, and not numbers, then this
    function will 'clean them up' to be floats.
Work around a JSON dict with string not float lat / lngs . Given anything ( list / dict / etc ) it will return that thing again * but * any dict ( at any level ) that has only 2 elements lat & lng will be replaced with the lat & lng turned into floats . If the API returns the lat / lng as strings and not numbers then this function will clean them up to be floats .
def floatify_latlng(input_value):
    """
    Work around a JSON dict with string, not float, lat/lngs.
    Given anything (list/dict/etc) it will return that thing again, *but* any
    dict (at any level) that has only 2 elements lat & lng, will be replaced
    with the lat & lng turned into floats.
    If the API returns the lat/lng as strings, and not numbers, then this
    function will 'clean them up' to be floats.
    """
    if isinstance(input_value, collections.Mapping):
        if len(input_value) == 2 and sorted(input_value.keys()) == ['lat', 'lng']:
            # This dict has only 2 keys 'lat' & 'lon'
            return {'lat': float_if_float(input_value["lat"]), 'lng': float_if_float(input_value["lng"])}
        else:
            return dict((key, floatify_latlng(value)) for key, value in input_value.items())
    elif isinstance(input_value, collections.MutableSequence):
        return [floatify_latlng(x) for x in input_value]
    else:
        return input_value
def floatify_latlng ( input_value ) : if isinstance ( input_value , collections . Mapping ) : if len ( input_value ) == 2 and sorted ( input_value . keys ( ) ) == [ 'lat' , 'lng' ] : # This dict has only 2 keys 'lat' & 'lon' return { 'lat' : float_if_float ( input_value [ "lat" ] ) , 'lng' : float_if_float ( input_value [ "lng" ] ) } else : return dict ( ( key , floatify_latlng ( value ) ) for key , value in input_value . items ( ) ) elif isinstance ( input_value , collections . MutableSequence ) : return [ floatify_latlng ( x ) for x in input_value ] else : return input_value