python-json-pointer

Resolve and apply RFC 6901 JSON Pointers against Python data structures.

Library
PyPI
v3.1.1
149stars
BSD 3-Clause License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
39/100Needs Attention
Development Activity8
Maintenance0
Community76
Maturity60
Momentum12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
76/100Good
Architecture72
Code Quality78
Innovation65
Learning Curve90

jsonpointer is a compact Python library that implements the JSON Pointer syntax defined in RFC 6901. It lets you address a specific value deep inside a nested JSON document (or an equivalent Python dict/list structure) using a simple slash-delimited pointer string, then read or modify that value.

The library is a widely used dependency across the Python ecosystem — notably as a building block for JSON Patch tooling — and ships both an importable API and a small command-line utility.

What You Get

  • A resolve_pointer function for one-shot lookups of a value by pointer
  • A reusable JsonPointer class that can be applied to multiple documents
  • A set_pointer helper for writing values at a pointer location
  • A jsonpointer command-line tool for resolving pointers against JSON files

Common Use Cases

  • Extracting a specific nested value from a large JSON payload
  • Implementing JSON Patch or JSON Reference behavior on top of pointers
  • Referencing configuration or schema fragments by a stable pointer path

Under The Hood

Architecture - The entire implementation lives in a single module, jsonpointer.py (~350 lines). A JsonPointer object parses a pointer string into a list of unescaped parts in its constructor, and resolution walks the document part by part, dispatching on whether the current node is a mapping or a sequence. Escaping of ~0/~1 and end-of-array (-) tokens is handled during parsing, and resolve_pointer/set_pointer are thin wrappers over the class.

Tech Stack - Pure Python with no runtime dependencies, targeting a broad range of Python 3 versions. Packaging is via setuptools (setup.py/setup.cfg), and a console_scripts entry point exposes the jsonpointer CLI.

Code Quality - The project has a substantial test suite (tests.py, ~400 lines) exercising resolution, escaping edge cases, and error conditions, and it tracks coverage via Coveralls. The code is mature and stable, having been maintained since 2011, with clear exceptions (JsonPointerException) for malformed pointers and missing members.

API Design - The public surface is intentionally minimal and predictable: a function for quick resolution and a class for reuse. Pointers are plain strings, default values can be supplied for missing members, and the same object can be applied across many documents, keeping everyday usage to one or two lines.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search