JSON Pointer for Python

3.1.1 · active · verified Sat Mar 28

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.

Warnings

Install

Imports

Quickstart

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

view raw JSON →