

def _json_convert(obj):
    'Recursive helper method that converts BSON types so they can be\n    converted into json.\n    '
    if (hasattr(obj, 'iteritems') or hasattr(obj, 'items')):
        return SON(((k, _json_convert(v)) for (k, v) in iteritems(obj)))
    elif (hasattr(obj, '__iter__') and (not isinstance(obj, (text_type, bytes)))):
        return list((_json_convert(v) for v in obj))
    try:
        return default(obj)
    except TypeError:
        return obj

dataset/ETHPy150Open mongodb/mongo-python-driver/bson/json_util.py _json_convert/original