def _json_convert(obj):
    """Recursive helper method that converts BSON types so they can be
    converted into json.
    """
    from numpy import ndarray
    if hasattr(obj, 'iteritems') or hasattr(obj, 'items'):  # PY3 support
        return SON(((k, _json_convert(v)) for k, v in obj.iteritems()))
    elif hasattr(obj, '__iter__') and not isinstance(obj, string_types) and not isinstance(obj, ndarray):
        return list((_json_convert(v) for v in obj))
    try:
        return default(obj)
    except __HOLE__:
        return obj
dataset/ETHPy150Open OpenMDAO/OpenMDAO-Framework/openmdao.lib/src/openmdao/lib/casehandlers/pymongo_bson/json_util.py/_json_convert