Skip to content

Main content

JSON Pointer Common Prefix Length Tool

Calculate json pointer common prefix length from explicit caller-supplied inputs.

Loading tool…

Description

Parse and decode slash-delimited tokens, replacing ~1 with slash and ~0 with tilde after validating escapes.

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.

Parse and decode slash-delimited tokens, replacing ~1 with slash and ~0 with tilde after validating escapes.

When to use this tool

Use JSON Pointer Common Prefix Length when you need a pointer token, depth, or representation check.

How to use the tool and how it works

  1. Enter firstPointer, secondPointer. Use the units and conventions below.
  2. Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
  3. Read commonSegments. Use the output convention below.

Parse and decode slash-delimited tokens, replacing ~1 with slash and ~0 with tilde after validating escapes. Count equal leading decoded tokens across both pointers.1

Input fieldMeaning and unitsAccepted input
firstPointerFirst PointerRequired. Text; maximum UTF-16 length 8192.
secondPointerSecond PointerRequired. Text; maximum UTF-16 length 8192.
Output fieldInterpretationReturned shape
commonSegmentsCommon SegmentsRequired. Safe integer.
json
{
  "input": {
    "firstPointer": "/a/b",
    "secondPointer": "/a/c"
  },
  "output": {
    "commonSegments": 1
  }
}

Limitations and assumptions

  • The result counts whole segments, not matching characters or a common existing document ancestor.
  • 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

  1. Calculation and input contract: json/json-pointer-common-prefix-length — tool.io

Similar or alternative tools