Description
Count zero segments for root or the slash-separated token count otherwise.
JSON Pointer separates path tokens with slashes and escapes literal slash and tilde inside member names. The empty pointer denotes the document root; an empty token can name an actual empty-string member.
Count zero segments for root or the slash-separated token count otherwise.
When to use this tool
Use JSON Pointer Root Distance when you need a pointer token, depth, or representation check.
How to use the tool and how it works
- Enter pointer. Use the units and conventions below.
- Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
- Read segments. Use the output convention below.
Require an empty pointer or slash-prefixed text without malformed tilde escapes. Count zero segments for root or the slash-separated token count otherwise.1
| Input field | Meaning and units | Accepted input |
|---|---|---|
| pointer | Pointer text in the exact syntax accepted by this tool. | Required. Text; maximum UTF-16 length 8192. |
| Output field | Interpretation | Returned shape |
|---|---|---|
| segments | Segments | Required. Safe integer. |
{
"input": {
"pointer": "/a/~1b"
},
"output": {
"segments": 2
}
} Limitations and assumptions
- This measures syntactic pointer depth rather than a traversal through an existing document.
- Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.
Alternative or Complementary methods
Use a complete pointer parser and resolve against the actual document when existence or array access matters.
References
Similar or alternative tools
- JSON Pointer Terminal Empty Segment
Count slash-separated tokens and mark terminalEmpty for a trailing slash.
- JSON Path Array Depth
Require every segmentKinds entry to be object or array and count the array entries as arrayDepth.