JSON Pointer vs JSONPath: Standards Explained
Compare the two fundamental addressing mechanisms defined by the IETF: deterministic RFC 6901 JSON Pointers versus expressive RFC 9535 JSONPath query expressions.
1. Head-to-Head Comparison
| Feature / Attribute | JSON Pointer (RFC 6901) | JSONPath (RFC 9535) |
|---|---|---|
| Primary Purpose | Exact single-target addressing | Complex multi-result querying & filtering |
| Syntax Delimiter | Forward slash: /users/0/name | Dot / Bracket: $.users[0].name |
| Cardinality of Results | Exactly 1 value (or null) | 0, 1, or multiple matches (array) |
| Wildcard & Filter Support | No (strictly deterministic) | Yes (*, .., [?(@.age > 21)]) |
| Primary Standards Usage | JSON Patch (RFC 6902), JSON Schema $ref | API testing, Kubernetes jsonpath, logging |
2. The RFC 6901 Escaping Rules: Why ~1 and ~0 Exist
In JSON Pointer, path segments are separated by forward slashes (/). If an object key itself contains a literal forward slash or tilde, RFC 6901 mandates exact escape sequences:
- ~1 represents a slash (/): The key
"a/b"is referenced as/a~1b. - ~0 represents a tilde (~): The key
"m~n"is referenced as/m~0n.
Order of evaluation matters: tildes must be unescaped after splitting the pointer on unescaped forward slashes.
Frequently Asked Questions
Q: What is the key difference between JSON Pointer and JSONPath?
JSON Pointer (RFC 6901) is an exact, deterministic addressing syntax that identifies exactly ONE specific value within a JSON document (e.g., '/store/books/0/title'). JSONPath (RFC 9535) is an expressive query language that supports wildcards, slices, and conditions to return ZERO, ONE, or MULTIPLE values.
Q: How do you escape slashes and tildes in JSON Pointer?
Because JSON Pointer uses the forward slash ('/') as a path delimiter, literal slashes within key names must be escaped as '~1', and literal tildes must be escaped as '~0'. For example, the key 'a/b' is addressed as '/a~1b'.
Q: Why does JSON Patch use JSON Pointer instead of JSONPath?
JSON Patch (RFC 6902) requires unambiguous, single-target operations ('add', 'remove', 'replace'). If an expression could match multiple elements or zero elements ambiguously, atomic patching operations would become non-deterministic. JSON Pointer guarantees exact target resolution.
References, Specifications & Primary Citations
In accordance with our strict Editorial Research & Citation Policy, every technical assertion is substantiated by primary standards, peer-reviewed computer science literature, or verified empirical benchmarks.
- Primary Standard SpecificationAuthor(s): Paul Bryan, Kris Zyp, Mark Nottingham Publisher / Org: Internet Engineering Task Force (IETF) Date: April 2013 Version/Rev: Proposed Standard
“Defines deterministic addressing syntax, escape sequences (~1 and ~0), and evaluation semantics.”
- Primary Standard SpecificationAuthor(s): Stefan Gössner, Carsten Bormann, Tim Bray (Eds.) Publisher / Org: Internet Engineering Task Force (IETF) Date: February 2024 Version/Rev: Proposed Standard
“Official IETF standard for JSONPath query syntax, selectors, filter expressions, and function extensions.”
- Primary Standard SpecificationPublisher / Org: Internet Engineering Task Force (IETF) Date: April 2013
“Specifies JSON Patch document structures using RFC 6901 target pointers.”
Copy RFC 6901 Pointers with 1 Click
Click any property in our free 2D graph visualizer to automatically copy its exact RFC 6901 pointer.