import pathlib


def json_path_serializer(obj):
    """Used to convert pathlib.Path to str in metadata"""
    if isinstance(obj, pathlib.Path):
        return str(obj)
    else:
        raise TypeError(f"TypeError: Object of type {obj.__class__} "
                        + "is not JSON serializable")