ysskrishna logoysskrishna

Nested Utils

Deep JSON and config paths, one string, no guard maze.

Built with
PyPI Packages
Python
uv
PyPI
GitHub Actions
Pytest
Details
FreeMIT licenseCreated December 6, 2025Updated November 12, 2026
Share this product

The API response goes five levels deep. Your code goes five lines wide.

You need one field. Maybe it lives under users, then the first item, then profile, then name. You start chaining checks. Each missing key is another branch. The readable logic disappears into guards.

nestedutils keeps plain dicts and lists. You pass a path like a single string and get the value, set it, or check it exists.

One path string beats a hallway of if statements.

What you get

  • Read deep values without a guard script. Pull a field from nested dicts and lists with a dot path. Pass a default when the path might be missing.
  • Write where the structure is not built yet. Turn on auto-creation and missing containers appear as dicts or lists while you set the value.
  • Know before you dig. Ask whether a path exists before you rely on it, instead of guessing from exceptions.
  • Change or remove without losing your place. Update a nested value or delete a key while the rest of the tree stays a normal Python structure.
  • See the shape when JSON gets weird. Helpers report depth, leaf count, and every path so debugging messy payloads takes less guesswork.
  • Free, small, and dependency-free. Pure Python, MIT licensed, on PyPI for Python 3.8 and up.

Picture your Tuesday

An illustrative case: a webhook drops a nested JSON blob on your desk. You need the customer email three levels in, and you might need to stash a new flag under settings later. One path string gets the email. Another, with create turned on, adds the flag without hand-building empty dicts first. No custom wrapper class. The data stays dicts and lists you already know.

Not writing code yet? Try it in your browser

The interactive playground runs the same helpers on sample JSON. Edit the data, switch examples, and copy the Python that matches what you tried.

Ready to try it?

Frequently asked questions

Why not just chain get with empty dict defaults?

That works for shallow paths. It gets long fast, and it breaks when an intermediate value is None instead of a dict. A path string keeps the read in one place, with an optional default when you want a soft miss.

How do I safely get a value from a nested dictionary in Python?

Install nestedutils, import get_at, and pass your data plus a dot path such as users.0.profile.name. Add a default if the path might be absent. Without a default, a missing path raises a clear path error instead of failing deep inside your own loops.

How do I access nested JSON with dot notation?

Use the same dot path for dict keys and list indices. Negative indices work like Python list indexing when the element already exists. Keys that contain dots can use a list-style path instead of a string.

How do I set a value when the nested containers are not there yet?

Call set_at with create turned on. Missing intermediate dicts and lists are created for you. Lists must grow in order: you cannot leave gaps at blank indices.

Can I try it without installing anything?

Yes. Open the interactive playground in your browser, load an example or paste JSON, and run reads, writes, and checks from the tabs there.

Does deleting from a nested list shift everything?

By default, list deletion is off. Turn on list mutation only when you accept that removing an index will shift what follows.

Is it a schema validator for untrusted JSON?

No. It navigates and mutates structures you already trust for shape. Pair it with real validation when input comes from the open internet.

Is it free?

Yes. MIT licensed, open source on GitHub and PyPI.

Continue exploring

ProductPyPISocial Links

Social Links

Users paste messy profile links. One Python library turns them into clean, comparable URLs.
PyPI Packages
Python
+4
ProductPyPIPyPI Package Stats

PyPI Package Stats

PyPI download counts, version mix, and package facts in one call, with disk caching built in.
PyPI Packages
Python
+6
ProductPyPIQuotes Convert

Quotes Convert

Flip single and double quotes in text without breaking nested escapes.
Text & Data Conversion
PyPI Packages
+5
ProductPyPIDocker Detector

Docker Detector

One call tells your Python app whether it is running inside Docker.
DevOps & Infrastructure
PyPI Packages
+6
ProductPyPIOSC 7501

OSC 7501

Tell your terminal when your CLI is working, blocked, finished, or failed.
DevOps & Infrastructure
PyPI Packages
+6
ProductPyPIContainer Detect

Container Detect

One Python call to learn if your process is inside Docker, Podman, Kubernetes, or another Linux container.
DevOps & Infrastructure
PyPI Packages
+7