Skip to content

Main content

JSON: JSON Newline Literal Escape Check Tool

Locate raw CR/LF code units in a caller-supplied JSON string-content fragment; escaped backslash-n text is not a raw line break and whole-string validity is not inferred.

Loading tool…

Description

Find literal linefeeds and carriage returns in fragment and return their zero-based UTF-16 offsets and a combined forbidden-raw-line-break flag.

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.

Find literal linefeeds and carriage returns in fragment and return their zero-based UTF-16 offsets and a combined forbidden-raw-line-break flag.

When to use this tool

Use JSON: JSON Newline Literal Escape Check 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.

Find literal linefeeds and carriage returns in fragment and return their zero-based UTF-16 offsets and a combined forbidden-raw-line-break flag.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.rawLinefeedOffsetsRaw Linefeed OffsetsCalculated result member: array.
result.rawCarriageReturnOffsetsRaw Carriage Return OffsetsCalculated result member: array.
result.hasForbiddenRawLineBreakHas Forbidden Raw Line BreakCalculated result member: boolean.
json
{
  "input": {
    "fragment": "a\nb"
  },
  "output": {
    "result": {
      "rawLinefeedOffsets": [
        1
      ],
      "rawCarriageReturnOffsets": [],
      "hasForbiddenRawLineBreak": true
    }
  }
}

Limitations and assumptions

  • This treats fragment as string content, not a whole document where whitespace between values may be legal; escaped backslash-n text is distinct.
  • 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-newline-literal-escape-check — tool.io

Similar or alternative tools