import json


def name2dict(name) -> dict:
    """ Converts JSON format string to dictionary.

    Args:
        name:: str
            A JSON format string. For example, "'penPair':'z1r'".

    Examples:
        >>> from fwig.tools import attributetools as at
        >>> name = "'penPair':'z1r','serif':'1'"
        >>> at.name2dict(name)
        {'penPair': 'z1r', 'serif': '1'}
    """
    if name is None:
        return {}
    name = '{' + name.replace("'", '"') + '}'
    name_dict = json.loads(name)

    return name_dict