import pathlib
import json


def load_json(filepath):
    """
    Loads the metrics in a dictionary.
    :param log_dir: The directory in which the log is saved
    :param metrics_file_name: The name of the metrics file
    :return: A dict with the metrics
    """

    if isinstance(filepath, pathlib.Path):
        filepath = str(filepath)

    if ".json" not in filepath:
        filepath = f"{filepath}.json"

    with open(filepath, "rb") as json_file:
        metrics_dict = json.loads(json_file.read())

    return metrics_dict