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

Serialize numbers and literals

02

Different number spellings can parse to the same binary64 value. JCS uses the specified ECMAScript serialization, with no whitespace between tokens.

RFC 8785 · § 3.2.2.3EXAMPLE
4 / 4
Serialize numbers and literalsA JSON input array contains 4.50,2e-3,1E30,null,true,false. Parsing yields binary64 values and literals. The third state emits compact ECMAScript-compatible spellings without inter-token whitespace. A separate programmatic Infinity case stops with an error and does not serialize as null.Numbers: spellings → values → spellingsProgram-created valueInfinityMUST terminate with errorNo null substitution · no outputNo recovery of precision lost while parsing
04
Stop a separate invalid programmatic input.

A program-created Infinity is not valid JSON. JCS fails rather than silently converting it to null.

Source for this drawing: RFC 8785 · Read RFC section 3.2.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

Canonicalize the parsed value, not its original spelling.

  • Numbers MUST use the ECMAScript number serialization specified in §3.2.2.3, including its Note 2 rule. Input decimals may round when parsed to binary64.
  • The literals null, true and false MUST serialize as null, true and false. Whitespace between JSON tokens MUST NOT be emitted; spaces inside strings remain data.
  • NaN and Infinity MUST cause an appropriate error. Higher precision or longer integers are RECOMMENDED as strings; Appendix D requires string wrapping for numbers outside the natural JSON ecosystem. Canonicalization does not recover precision already lost.
DETAILS

The figure uses small exact-value examples, not a decimal arithmetic algorithm. Appendix B supplies harder rounding/boundary vectors. Negative-zero parsing advice is in chapter one; do not confuse it with the underlying serializer’s 0 output.

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 ↗