Nested Utils

Dot-path access made easy for Python's JSON, dict, and list structures.

Dot-path get / set / delete for nested Python dicts and lists, without hand-written guards

nestedutils is a small, dependency-free Python library for navigating nested dicts, lists, and tuples (read-only for tuples) using string paths like users.0.profile.name or list paths when keys contain dots. It exposes get_at, set_at, delete_at, exists_at, plus helpers such as depth, leaf counts, and all paths, with PathError codes documented in the README.

When it is useful

You are parsing JSON APIs, editing config trees, or remapping nested payloads and want less boilerplate than chained try / .get patterns. Install from PyPI; docs and a browser playground are linked from the repository.

What you can do

  • Read deep values with optional defaults, or write with create=True to add missing intermediate containers where the API allows.
  • Use negative list indices for existing elements, introspection helpers for debugging shape, and safety limits (documented max depth and index bounds) to catch runaway paths.
  • Follow the v2 migration notes if you upgrade from older major versions.

Limits

  • It is a data-navigation helper, not a schema validator; pair with real validation for untrusted input.
  • List deletion is deliberately guarded; understand allow_list_mutation before mutating lists in place.
  • Behavior and edge cases are defined by the published API; always check the version you pinned in production.

Frequently asked questions

What is Nested Utils for?

It is a small, dependency-free Python library for reading and writing nested dicts, lists, and tuples (tuples are read-only) with string paths like users.0.profile.name or list paths when keys contain dots.

How do I install it?

Install from PyPI with pip install nestedutils (Python 3.8+), then import helpers such as get_at, set_at, delete_at, and exists_at.

Can it create missing nested containers when writing?

Yes. Call set_at with create=True to add missing intermediate containers where the API allows. Use optional defaults on get_at, negative list indices for existing elements, and introspection helpers like get_depth, count_leaves, and get_all_paths.

Is list deletion safe by default?

List deletion is guarded: delete_at leaves lists alone unless you pass allow_list_mutation=True, because deleting list items can shift indexes. It is a navigation helper, not a schema validator, so pair it with real validation for untrusted input.

Continue exploring