from typing import Dict
from typing import Any
import json
import yaml


def read_object_from_file(filename: str) -> Dict[str, Any]:
    """Read dictionary serialization from file. The file format is expected to
    by Yaml unless the filename ends with .json.

    Parameters
    ----------
    filename: string
        Name of the input file

    Returns
    -------
    dict
    """
    with open(filename, 'r') as f:
        if filename.endswith('.json'):
            return json.loads(f.read())
        else:
            return yaml.load(f.read(), Loader=yaml.FullLoader)