from pathlib import Path
from typing import Dict
import json


def load_json_object(json_path: Path) -> Dict:
    """Attempts to load a single JSON object from a file.

    Raises a TypeError if the JSON parsing is successful but the file contained
    a JSON array.

    Keyword arguments:
    json_path (Path): Path to file to load a json object from.
    """
    with json_path.open("r") as infile:
        json_dict = json.load(infile)
        if not isinstance(json_dict, dict):
            raise TypeError("Contents of ", json_path, " is not one JSON object")

        return json_dict