Skip to main content

exclude_field_by_value

No overview available.

def exclude_field_by_value(
data: dict,
field_name: string,
value_to_exclude: any
) - > dict

Removes a specific field from a dictionary if its value matches a target value, typically used to prune default or null values before serialization.

Parameters

NameTypeDescription
datadictThe source dictionary containing the fields to be evaluated for exclusion.
field_namestringThe key within the dictionary to check for the exclusion criteria.
value_to_excludeanyThe specific value that triggers the removal of the field if a match is found.

Returns

TypeDescription
dictA copy of the input dictionary with the specified field removed if the value condition was met; otherwise, the original dictionary structure.