def format_response_data(sparkl_response):
    """
    Builds easy-access object from response data sent back by SPARKL.
    """

    # Get name of response/reply and list of output fields
    try:
        response_name = sparkl_response['attr']['name']
        fields_data_list = sparkl_response['content']

    # Return full response in case of error event (i.e. if mix fails to
    # execute)
    except KeyError:
        return sparkl_response

    # Build object from field name/value pairs
    fields_object = {}
    for field in fields_data_list:
        field_name = field['attr']['name']

        # Flag fields have no value, add value only if not FLAG
        field_value = None

        # If field has value, its value is first element of content list
        if 'content' in field:
            field_value = field['content'][0]

        # Add field name/value to fields dictionary
        name_value_pair = {field_name: field_value}
        fields_object.update(name_value_pair)

    return_data = {
        'response': response_name,
        'fields': fields_object
    }

    return return_data