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
- Enter text. Use the units and conventions below.
- Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
- 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 field | Meaning and units | Accepted input |
|---|---|---|
| text | Text | Required. Text. Implementation limit: 8192 Unicode code points and 16384 UTF-16 code units. |
| Output field | Interpretation | Returned shape |
|---|---|---|
| result | Result | Required. Object. |
| result.terminalComma | Terminal Comma | Calculated result member: boolean. |
| result.commaOffset | UTF-16 index of the matched terminal comma, or -1 when absent. | Calculated result member: number. |
{
"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
Similar or alternative tools
- JSON Lines Terminal Newline State
Reject carriage returns, split nonempty text on linefeeds, and drop one final terminator entry.
- JSON Array Singleton Unwrapper
Parse json as an array, require exactly one element, and serialize that element into valueJson.