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.
pip install jsonpointerVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to use JsonPointer to access a specific value in a JSON document.
Use 'from jsonpointer import JsonPointer' to import the class.
pip install jsonpointer
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.
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.
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.
No dependency data recorded yet.