def make_serializable(o):
    "\n    Recursively convert numpy types to native types for JSON serialization.\n\n    This function should NOT be passed into json.dump or json.dumps as the 'default' arg.\n\n    Parameters\n    ----------\n    o : object\n        The object to be converted.\n\n    Returns\n    -------\n    object\n        The converted object.\n    "
    if isinstance(o, _container_classes):
        return [make_serializable(item) for item in o]
    elif isinstance(o, dict):
        s_key = [make_serializable_key(item) for item in o.keys()]
        s_val = [make_serializable(item) for item in o.values()]
        return dict(zip(s_key, s_val))
    elif isinstance(o, np.ndarray):
        return o.tolist()
    elif isinstance(o, np.number):
        return o.item()
    elif isinstance(o, (str, float, int)):
        return o
    elif (isinstance(o, bool) or isinstance(o, complex)):
        return str(o)
    elif hasattr(o, '__dict__'):
        try:
            return o.to_json()
        except AttributeError:
            return o.__class__.__name__
    else:
        return o
Recursively convert numpy types to native types for JSON serialization.

This function should NOT be passed into json.dump or json.dumps as the 'default' arg.

Parameters
----------
o : object
    The object to be converted.

Returns
-------
object
    The converted object.
def make_serializable(o):
    "\n    Recursively convert numpy types to native types for JSON serialization.\n\n    This function should NOT be passed into json.dump or json.dumps as the 'default' arg.\n\n    Parameters\n    ----------\n    o : object\n        The object to be converted.\n\n    Returns\n    -------\n    object\n        The converted object.\n    "
    if isinstance(o, _container_classes):
        return [make_serializable(item) for item in o]
    elif isinstance(o, dict):
        s_key = [make_serializable_key(item) for item in o.keys()]
        s_val = [make_serializable(item) for item in o.values()]
        return dict(zip(s_key, s_val))
    elif isinstance(o, np.ndarray):
        return o.tolist()
    elif isinstance(o, np.number):
        return o.item()
    elif isinstance(o, (str, float, int)):
        return o
    elif (isinstance(o, bool) or isinstance(o, complex)):
        return str(o)
    elif hasattr(o, '__dict__'):
        try:
            return o.to_json()
        except AttributeError:
            return o.__class__.__name__
    else:
        return o