import json


def json_to_str(d):
    """
    Serialize dict 'd' to a JSON formatted string.

    Args:
        d: dictionary to be serialized
    Raises:
        TypeError: 'd' is not a list or dict

    Examples:
    >>> json_to_str({})
    '{}'
    >>> json_to_str({'a':1,'b':2,'c':{'d':3}})
    '{"a": 1, "c": {"d": 3}, "b": 2}'
    >>> json_to_str({1})
    Traceback (most recent call last):
        ...
    TypeError: Argument not a list or dict
    """
    if not isinstance(d, dict) and not isinstance(d, list):
        raise TypeError('Argument not a list or dict')
    return json.dumps(d)