Home / Docs / Specification / 29. Numerics
29.10 JSON
Release v0.4.0
- Parsing is unchanged. A JSON number with a fraction or an exponent stays
Decimal(text)(spec/23 §1). as_f64(j)gives, forNumber(n),Some(n.to_f64()); forDecimal(t),Someofparse_f64(t), which never fails on aJsonNumber; andNonefor every otherJson. A number beyond the range givesSomeof an infinity.json_number(x)givesSome(Decimal(t))withtthe rendering of §7 for a finitex, andNonefor NaN and the infinities.-0.0givesDecimal("-0.0").- Round trip. For every finite
x,json_number(x), written byto_json, read byparse_jsonand converted byas_f64, givesSome(x), bit for bit. - Labels. Both functions label their result with their argument's labels.