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

Sort names, keep array order

04

Object property order becomes deterministic at every depth. Arrays keep their element order, even while objects inside them have their names sorted.

RFC 8785 · § 3.2.3EXAMPLE
5 / 5
Sort names, keep array orderRoot b,a is reordered a,b. Array a retains element0 then element1 while their d,c and z,y properties sort to c,d and y,z. Separate examples compare UTF-16 D83D DE00 before FF21, and numeric-looking property names10 before2. Arrays are never reordered and names are compared in raw decoded form.Sort object names · retain array positions{"2":"two","10":"ten"}First unit: "1" (0031) < "2" (0032)raw string comparison{"10":"ten","2":"two"}Emit in sorted order · numeric keys are strings
05
Compare numeric-looking names as strings.

A separate object orders "10" before "2". Emit that order explicitly rather than relying on integer-key enumeration.

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

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

Sort object names recursively; never sort array elements.

  • Properties MUST be sorted recursively, including objects found inside arrays. Array element order MUST NOT change.
  • Compare raw, unescaped property names as unsigned UTF-16 code units, independent of locale. At the first differing unit, the smaller comes first; an otherwise equal prefix puts the shorter name first.
  • UTF-8 byte order or Unicode code-point order can disagree with UTF-16 order. Also, numeric-looking keys are strings: "10" precedes "2". An ordinary object serializer that reorders integer keys is not by itself a JCS canonicalizer.
DETAILS

The worked input has nested objects and a two-element array. The separate supplementary-character comparison uses U+1F600 (D83D DE00) versus U+FF21: D83D is smaller than FF21, so the emoji name sorts first. No locale collation or normalization is involved.

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 ↗