Skip to content

Main content

JSON Array Append Position Token Tool

Resolve a supplied final array token for an insertion context; - is special only for add.

Loading tool…

Description

Validate operation and nonnegative length.

JSON Patch describes operations at pointer locations, and operation context determines whether a location is usable. Array append tokens, root targets, and scalar equality have narrow semantics.

Validate operation and nonnegative length.

When to use this tool

Use JSON Array Append Position Token when you need one explicit patch-context check.

How to use the tool and how it works

  1. Enter token, operation, length. 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 appendAllowed, insertionIndex. Inspect appendAllowed before interpreting the associated values.

Validate operation and nonnegative length. For dash with add, return appendAllowed and insertionIndex equal to length; otherwise accept a canonical safe numeric token up to length, or return -1.1

Input fieldMeaning and unitsAccepted input
tokenTokenRequired. Text; maximum UTF-16 length 8192.
operationOperationRequired. Text; one of "add", "remove", "replace", "test"; maximum UTF-16 length 8192.
lengthLength, count, or code length under the stated domain and unit convention.Required. Safe integer; minimum 0.
Output fieldInterpretationReturned shape
appendAllowedAppend AllowedRequired. Boolean.
insertionIndexInclusive insertion position 0 through length or -1; not a general access-validity verdict.Required. Safe integer.
json
{
  "input": {
    "token": "-",
    "operation": "add",
    "length": 3
  },
  "output": {
    "appendAllowed": true,
    "insertionIndex": 3
  }
}

Limitations and assumptions

  • The inclusive numeric upper bound applies even to non-add operations in this narrow helper; it does not establish access validity for remove, replace, or test.
  • 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.
  • Numeric calculations use binary floating point unless exact decimal-integer arithmetic is explicitly stated. No hidden measurement tolerance or decimal rounding is added; nonfinite or out-of-contract results are rejected. Numeric signed-zero results are exported as zero.

Alternative or Complementary methods

Validate and apply the full patch transaction against the actual document using a conforming implementation.

References

  1. Calculation and input contract: json/json-array-append-position-token — tool.io

Similar or alternative tools