Skip to content

Main content

JSON: JSON Array Terminal Comma Position Tool

Inspect the lexical comma-before-final-bracket pattern in one declared JSON-array fragment; not a general JSON parser and does not remove commas or accept invalid JSON.

Loading tool…

Description

Detect a comma followed only by whitespace and the final bracket, returning its offset or -1.

A JSON lexeme is its textual spelling, which differs from the decoded value. Escapes, quotes, raw control characters, and surrounding whitespace must be interpreted in context.

Detect a comma followed only by whitespace and the final bracket, returning its offset or -1.

When to use this tool

Use JSON: JSON Array Terminal Comma Position when you need a narrowly defined JSON string or separator diagnostic.

How to use the tool and how it works

  1. Enter text. 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 result. Expand result to inspect the returned fields.

Require opening and closing square-bracket shapes with surrounding JavaScript whitespace allowed. Detect a comma followed only by whitespace and the final bracket, returning its offset or -1.1

Input fieldMeaning and unitsAccepted input
textTextRequired. Text. Implementation limit: 8192 Unicode code points and 16384 UTF-16 code units.
Output fieldInterpretationReturned shape
resultResultRequired. Object.
result.terminalCommaTerminal CommaCalculated result member: boolean.
result.commaOffsetUTF-16 index of the matched terminal comma, or -1 when absent.Calculated result member: number.
json
{
  "input": {
    "text": "[1, 2, ]"
  },
  "output": {
    "result": {
      "terminalComma": true,
      "commaOffset": 5
    }
  }
}

Limitations and assumptions

  • This is a terminal-pattern detector, not an array parser; commas inside a final string or malformed content can produce misleading matches.
  • Outputs are nested inside result. 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

Parse the entire document when validity matters; a local pattern match cannot establish complete JSON syntax.

References

  1. Calculation and input contract: json/json-array-terminal-comma-position — tool.io

Similar or alternative tools