dictutils.ops.deep_delΒΆ

dictutils.ops.deep_del(obj, path)[source]ΒΆ

Delete value from nested object using dotted path notation.

Parameters:
  • obj (Any) – The object to modify

  • path (Union[str, Sequence[Union[str, int]]]) – Path as string (β€œa.b.c”) or sequence [β€œa”, β€œb”, β€œc”]

Return type:

Any

Returns:

The modified object

Example

>>> import json
>>> data = {"user": {"profile": {"name": "Alice", "age": 30}}}
>>> deep_del(data, "user.profile.age")
>>> print(json.dumps(data, indent=4))
{
    "user": {
        "profile": {
            "name": "Alice"
        }
    }
}