Skip to main content

mapping_get

No overview available.

def mapping_get(
data: Union[dict, list],
keys: Iterable,
default: any = None
) - > any

Retrieves a value from a nested dictionary or list structure using a sequence of keys. This function allows for safe traversal of complex data structures by returning a default value if any key in the path is missing.

Parameters

NameTypeDescription
dataUnion[dict, list]The root mapping or sequence object to be traversed.
keysIterableA sequence of keys or indices representing the path to the desired value.
defaultany = NoneThe value to return if a key is not found or an index is out of range during traversal.

Returns

TypeDescription
anyThe value found at the end of the key path, or the provided default value if the path is unreachable.