from typing import Union
from typing import Dict
import pathlib
import json


def read_json(fn: Union[Dict, str, pathlib.Path]) -> Dict:
    """
    Read file and output dict, or take dict and output dict.


    Parameters
    ----------
    fn : Union[Dict, str, pathlib.Path]


    Returns
    -------
    dict

    """
    if isinstance(fn, dict):
        return fn

    with open(fn, "r") as f:
        data = json.load(f)
    return data