1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//! The seam where admission hands off to canonicalization.
//!
//! This crate refuses; it does not serialize. `serde_json_canonicalizer` 0.3.2
//! implements RFC 8785 section 3.2.2.3 over `ryu_js`, which is the ECMAScript
//! `Number::toString` variant the section requires rather than a general float
//! formatter, and it had 5,259,528 recent downloads when this crate chose it
//! (crates.io API, 2026-09-19). Writing a third implementation of that algorithm
//! would add a way for the rails to disagree and nothing else.
//!
//! So the whole of this file is one `Serialize` impl. A [`Node`] that reached
//! here is already admitted: its members are unique, its strings are sequences of
//! Unicode scalar values, its nesting is inside the cap, and its number tokens
//! have finite doubles. What remains is laying out bytes, and that is the
//! delegate's job.
//!
//! # Why the number goes through `str::parse` here
//!
//! `Node::Number` holds the token exactly as it was written, and the double is
//! taken from it with `str::parse::<f64>`, which is correctly rounded. Routing
//! the token through a JSON library instead would put a second parser in the
//! path: `serde_json` reads `333333333.33333329` -- the number in the RFC's own
//! reference vectors -- one unit in the last place low unless its
//! `float_roundtrip` feature is on. The delegate does turn that feature on, so
//! both readings agree today (measured 2026-09-19: `pipe("333333333.33333329")`
//! returns `333333333.3333333`, and `str::parse` gives bits `0x41b3de4355555555`).
//! Parsing the token here does not depend on that staying true.
use ;
use ;
use crateNode;