from pathlib import Path
import csv
import json


def csv_to_json(file_obj: Path):
    """Convert a csv file to json.

    Parameters
    ----------
    file_obj : Path
        A path to a csv file

    Returns
    -------
    str
        JSON encoded object

    """
    if not file_obj.is_file():
        raise FileNotFoundError

    with open(file_obj) as f:
        csv_file = list(csv.reader(f))
        return json.dumps(csv_file)