Visual RFC.
ALL RFCs / RFC 8785
Read the RFC ↗
RFC 8785 / REPEATABLE JSON BYTES

Preserve strings, choose escapes

03

A character can arrive through an escape or directly. Decode it, preserve the resulting Unicode data, then serialize with the required escapes.

RFC 8785 · § 3.2.2.2EXAMPLE
4 / 4
Preserve strings, choose escapesThe first state decodes escaped JSON into é, newline,U+000F,quote,backslash,slash. The next emits the same character sequence using required escapes and literal é/slash. Separate comparisons retain U+00E9 versus U+0065 U+0301 without normalization, and stop changing a subtype string055 to55 before canonicalization.Keep the characters · choose required escapes{"big":"055"}Preserve JSON stringrewrite to "55"Conversion belongs in a later application stepCanonicalized string remains "055"
04
Keep the original string for canonicalization.

The application may interpret "055" as a big integer later. Replacing the canonicalized string with "55" changes the data and is stopped here.

Source for this drawing: RFC 8785 · Read RFC section 3.2.2.2 ↗

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

First, agree how to read the message.

An encoding tells a reader how to interpret bytes. A format tells it how values fit together. Correctly reading a value does not make that value trustworthy.

Helpful first, if these ideas are unfamiliar

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

Related RFCs and changes

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

KEY POINT

Changing a string’s meaning is not canonicalization.

  • Control characters U+0000–U+001F MUST use lowercase \uhhhh, except backspace, tab, newline, form feed and carriage return, which MUST use \b, \t, \n, \f and \r. Quote and backslash MUST be escaped. Other valid characters are emitted as is, inside double quotes.
  • Parsed string data MUST NOT be altered during later serialization. JCS does not perform Unicode normalization: precomposed é and e plus combining acute remain distinct strings.
  • Appendix E requires stream/schema parsers to preserve subtypes as immutable JSON strings and convert to native types subsequently. A string such as "055" must not become "55" in the signed data.
DETAILS

The escape example includes é, newline, U+000F, a quote, a backslash and a slash. Slash does not need escaping in JCS. Verified editorial erratum 6292 corrects the referenced ECMAScript string algorithm to §24.5.2.2. Appendix E is additional reading: https://www.rfc-editor.org/rfc/rfc8785.html#appendix-E .

Read the RFC section ↗

All chapters in RFC 8785

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 ↗