import json


def json_parser(elem, **kwargs):
    """
    Deserialize ``elem`` (a ``str``, ``bytes`` or ``bytearray`` instance
    containing a JSON object) to a Python dictionary.

    Args:
        elem: JSON object in ``str``, ``bytes`` or ``bytearray``
        **kwargs:

    Returns:
        dict: resulting object as dictionary.

    Raises:
        ValueError: If `elem` is not serialized JSON object, for example if
            it is a serialized JSON list.
        TypeError: If `elem` is not a ``str``, ``bytes`` or ``bytearray``.
        JSONDecodeError: If there is something wrong with JSON format.
    """
    obj = json.loads(elem, **kwargs)
    if not isinstance(obj, dict):
        raise ValueError(f'Serialized JSON object was expected, got {type(obj)}')

    return obj