A python package for working with dotted and square-bracketed paths on a recursive data structure made of dicts and lists, such as are returned by most JSON and YAML decoders, and other common data interchange formats.
Warning
In development: public API is not stable, support available solely at developer discretion
- Public API Reference Document
- Requires Python 3.10+
- Example paths that refer to a single value:
hellohello.worldhello.world[0]hello.world[0].name
- Example iterable paths:
hello.world[].namehello.world[1:10:2].nameobjects[].attributes.*- iterates all values in each"attributes"dictobjects[].attributes.*hello*- same, but the key must contain the substringhello
- Dictionary keys may be any string excluding the characters
*,[, and. - List indicies within square brackets must parse to an integer
- For iteration:
- Dictionary keys may contain
*to iterate over all keys in the preceeding dictionary; iterating all keys matching a wildcard pattern is also supported - Square brackets may be empty to iterate over all items in the preceeding list
- The Python range syntax
[x:y:z]is fully supported - An
InvalidIterationErrorwill be raised if these iterable path parts are passed to functions other thaniterate().
- Dictionary keys may contain
- A
ValidationErrorwill be raised if the data structure does not match types of all path parts:- Strings keys (outside of square brackets) MUST correspond to an object that subclasses
dict - Numerical indicies (within square brackets) MUST correspond to an object that subclasses
list
- Strings keys (outside of square brackets) MUST correspond to an object that subclasses