nob: the Nested OBject manipulator

Nested Objects (nobs, often referred to simply as JSON objects) appear in many software workflows. They are combinations of key-value mappings (dicts) and sequences (lists) of data. Other, more human readable formats than JSON are useful to view this type of data, such as YAML:

shelters:
 kennel:
  dogs:
  - name: Rex
    age: 3
    alpha: False
  - name: Beethoven
    age: 8
    alpha: True

Their manipulation can become cumbersome in pure Python, in proportion to the complexity of their structure. With nob, accessing the first dog’s name is done with either of:

first = n['dogs'][0]['name'][:]
first = n.dogs[0].name[:]

and finding the alpha dog’s name with:

alpha = [nv for nv in n.dogs if nv.alpha[:]][0].name[:]

The industry standard to deal with nobs is known as Object Relational Mapping (ORMs). In ORMs, Python objects are defined in code to hold the nob data as attributes. This is a great abstraction, but in some cases nobs can have complex, uncertain structure, and it can be very difficult to build and ORM for them. Or, you just don’t want to deal with building an ORM. This is where nob comes in.

nob is a wrapper for nested objects that offers a set of functionalities to simplify their direct manipulation. In doing so, it strives to stay as close as possible to native python datatype interfaces, and to be intuitive for developers with Python habits.

User’s Guide

nob is meant to be intuitive, but there are some ideas you must have about the underlying data model in order to not be surprised by its behaviour. This part explores these ideas in both general and concrete form.

API Reference

You can dive into the specific functions of nob here.

Additional Notes

Miscellaneous information about the project.

Indices and tables