Visual RFC.
ALL RFCs / RFC 7464
Read the RFC ↗
RFC 7464 / JSON TEXT SEQUENCES

Detect possibly truncated scalars

04

Numbers, true, false and null need trailing JSON whitespace so a parser can reject potentially truncated values.

RFC 7464 · § 2.4EXAMPLE
3 / 3
Detect possibly truncated scalarsThree independent comparisons: 123 without whitespace must be dropped; 123 with LF is accepted; truefalse with LF remains invalid JSON. RS alone does not delimit a complete number safely.Check the trailing whitespace canaryIndependent comparisons · not consecutive recordsRStruefalseLFRSNext boundaryvalidate candidateREJECTWhitespace does not repair invalid JSONtruefalse is one invalid text, not two JSON values
03
Reject invalid JSON despite whitespace.

A trailing LF cannot turn truefalse into one valid JSON text.

Source for this drawing: RFC 7464 · Read RFC section 2.4 ↗

Protocol participantThreat or exceptionProtocol controlSimplified drawings · precise section references
New to this? Start hereA quick picture + helpful background

A message needs an address.

Think of a packet as a small addressed envelope. Devices pass it onward; transport protocols decide what delivery promises an application gets.

Helpful first, if these ideas are unfamiliar

These pictures are analogies to help you learn. The linked RFC explains the actual rules.

Terms in this drawing
Canary byte
A trailing byte whose absence can signal possible truncation.
Self-delimited
A value whose closing syntax identifies its end, such as a closing quote or brace.
Related RFCs and changes

“Updates” changes part of an earlier RFC. “Obsoletes” replaces it. This list shows selected related documents.

KEY POINT

Require a whitespace canary for non-self-delimited values.

  • Parsers MUST check that a top-level number, or text that might be true, false or null, has at least one JSON whitespace byte after that value. The encoder’s LF satisfies this check.
  • Parsers MUST drop non-self-delimited top-level elements that lack that whitespace and may have been truncated. For example, RS 123 RS might be a truncated 1234; a boundary alone is insufficient.
  • Whitespace does not repair invalid JSON: truefalse is not two values and is not a valid JSON text. Objects, arrays and strings are self-delimited; incremental parsers may produce these without consuming another byte. Detecting truncation still depends on encoders receiving or producing complete JSON texts.
DETAILS

Three independent comparisons are shown, not consecutive requests: 123 without trailing whitespace is dropped; 123 followed by LF passes this check and parses; truefalse followed by LF still fails JSON parsing. The acceptance example is a format-level result, not authentication or a promise of intact transport.

Read the RFC section ↗

All chapters in RFC 7464

Drawing view

Scroll the drawing to see every part. Playback controls stay above it.

RFC 9700 / CHAPTERS

Chapters

For full details, tables, algorithms, and exceptions, read the original RFC.

RFC status and corrections ↗