Registry / serialization / jsonpointer

jsonpointer

JSON →
library3.1.1pypypi✓ verified 52d ago

A Python library for identifying specific nodes in a JSON document, implementing RFC 6901. Current version: 3.1.1. Release cadence: Regular updates with active maintenance.

serialization
pip install jsonpointer
Install & Compatibility
Where this runs
tested against v3.1.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.925 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.925 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

JsonPointer
from jsonpointer import JsonPointer
Ensure correct import path to access JsonPointer class

Demonstrates how to use JsonPointer to access a specific value in a JSON document.

import json from jsonpointer import JsonPointer # Sample JSON document json_data = { "store": { "book": [ {"category": "reference", "author": "Nigel Rees", "title": "Sayings of the Century", "price": 8.95 }, {"category": "fiction", "author": "Evelyn Waugh", "title": "Sword of Honour", "price": 12.99 } ] } } # Create a JsonPointer instance pointer = JsonPointer('/store/book/0/author') # Resolve the pointer to get the value author = pointer.resolve(json_data) print(author) # Output: Nigel Rees
Debug
Known issues
breakingEnsure correct import path to access JsonPointer class
fix
Use 'from jsonpointer import JsonPointer' to import the class.
affects: 3.1.1
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'jsonpointer'
The 'jsonpointer' package has not been installed in your Python environment.
fix
pip install jsonpointer
jsonpointer.JsonPointerException: index X out of bounds in [...]
The JSON pointer attempts to access an array index that is outside the bounds of the array in the JSON document.
fix
Ensure the array index specified in the JSON pointer is within the valid range (0 to length-1) for the target array. You can inspect the JSON document or add logic to check array bounds before applying the pointer.
jsonpointer.JsonPointerException: JSON pointer must be empty or begin with '/'
The provided JSON pointer string does not conform to RFC 6901, as it does not start with a '/' character (unless it's an empty string for the root document).
fix
Correct the JSON pointer string to begin with a '/' (e.g., change 'foo/bar' to '/foo/bar') or use an empty string '' for the root document.
KeyError: 'some_key'
When using jsonpointer.resolve() or JsonPointer().get() without a 'default' argument, a KeyError is raised if a segment of the pointer path references a key that does not exist in a dictionary within the JSON document.
fix
Provide a 'default' argument to jsonpointer.resolve(doc, pointer, default=None) or JsonPointer(pointer).get(doc, default=None) to return a specified value instead of raising a KeyError when the path is not found. Alternatively, ensure the JSON document structure matches the expected pointer path or explicitly check for key existence.
Upgrade
Version history
3.1.1latest on PyPI
Audit
Dependencies

No dependency data recorded yet.

Agent activity
18 hits · last 30 days
node
6
seranking-bot
4
Amazon
2
ahrefsbot
2
Resources