Converts object to JSON formatted string with typeToken adapter
    :param data: A dictionary to convert to JSON string
    :param pretty: A boolean deciding whether or not to pretty format the JSON string
    :return: The JSON string

def to_json(data, pretty):
    """
    Converts object to JSON formatted string with typeToken adapter
    :param data: A dictionary to convert to JSON string
    :param pretty: A boolean deciding whether or not to pretty format the JSON string
    :return: The JSON string
    """
    if pretty:
        return json.dumps(data, sort_keys=True, indent=4, separators=(',', ': '))
    return json.dumps(data)