Skip to content

Main content

JSON: JSON String Trailing Backslash Parity Tool

Determine whether a hypothetical next quote is escaped from the exact trailing backslash-run parity of a fragment; not a full JSON string validator.

Loading tool…

Description

Count consecutive backslashes at fragment's end.

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.

Count consecutive backslashes at fragment's end.

When to use this tool

Use JSON: JSON String Trailing Backslash Parity when you need a narrowly defined JSON string or separator diagnostic.

How to use the tool and how it works

  1. Enter fragment. 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.

Count consecutive backslashes at fragment's end. Mark nextQuoteEscaped only when that count is odd.1

Input fieldMeaning and unitsAccepted input
fragmentFragmentRequired. Text. Implementation limit: 8192 Unicode code points and 16384 UTF-16 code units.
Output fieldInterpretationReturned shape
resultResultRequired. Object.
result.trailingBackslashesTrailing BackslashesCalculated result member: number.
result.nextQuoteEscapedNext Quote EscapedCalculated result member: boolean.
json
{
  "input": {
    "fragment": "abc\\\\\\"
  },
  "output": {
    "result": {
      "trailingBackslashes": 3,
      "nextQuoteEscaped": true
    }
  }
}

Limitations and assumptions

  • The fragment is not parsed as a full JSON string; the flag assumes the quote follows this run immediately inside a string.
  • 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-string-trailing-backslash-parity — tool.io

Similar or alternative tools