def format_dict_list(list_of_dicts, output_name, key=None):
        '''
            Utility method for formatting lists of dictionaries for api consumption.
            Takes something like [{name: val1, email: val2},{name: val1, email: val2}] for signers
            and outputs:
            signers[0][name]  : val1
            signers[0][email] : val2
            ... 

            Args:
                list_of_dicts (list of dicts) - the list to format
                
                output_name (str) - the parameter name to prepend to each key
                
                key (str, optional) - Used for substituting a key present in the dictionaries for the index. The above might become signers['Lawyer']['name'] instead of using a numerical index if the key "role_name" was specified.

        '''
        output_payload = {}
        if list_of_dicts:
            for index, dictionary in enumerate(list_of_dicts):
                index_or_key = dictionary[key] if key else str(index)
                base_name = output_name + '[' + index_or_key + ']'
                for (param, value) in dictionary.items():
                    if param != key: #key params are stripped
                        output_payload[base_name + '[' + param + ']'] = value
        return output_payload
def format_dict_list ( list_of_dicts , output_name , key = None ) : output_payload = { } if list_of_dicts : for index , dictionary in enumerate ( list_of_dicts ) : index_or_key = dictionary [ key ] if key else str ( index ) base_name = output_name + '[' + index_or_key + ']' for ( param , value ) in dictionary . items ( ) : if param != key : output_payload [ base_name + '[' + param + ']' ] = value return output_payload
Utility method for formatting lists of dictionaries for api consumption.
            Takes something like [{name: val1, email: val2},{name: val1, email: val2}] for signers
            and outputs:
            signers[0][name]  : val1
            signers[0][email] : val2
            ... 

            Args:
                list_of_dicts (list of dicts) - the list to format
                
                output_name (str) - the parameter name to prepend to each key
                
                key (str, optional) - Used for substituting a key present in the dictionaries for the index. The above might become signers['Lawyer']['name'] instead of using a numerical index if the key "role_name" was specified.