Documentation
¶
Overview ¶
Package jsonnumber reads a JSON number as it is written, for the reads that must keep an integer past 2^53 exact or print a number as its source wrote it. encoding/json/v2 decodes every number that lands in an any as a float64 and has no counterpart to v1's UseNumber; AsWritten is that counterpart.
It is not the reader of proofs, keyrings or source answers, which is internal/strictjson, and it applies none of SPEC.md section 10.1's rules beyond what encoding/json/v2 makes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var AsWritten = json.WithUnmarshalers(json.UnmarshalFromFunc(func(dec *jsontext.Decoder, v *any) error { if dec.PeekKind() != '0' { return errors.ErrUnsupported } raw, err := dec.ReadValue() if err != nil { return err } *v = jsontext.Value(bytes.Clone(raw)) return nil }))
AsWritten is an unmarshal option under which each JSON number decoded into an any, at any depth, is the jsontext.Value it is written as, and every other value decodes as it does by default. Such a number marshals again exactly as written, so "1.50" stays "1.50" and a ledger sequence is never re-printed as a float.
Functions ¶
func Float64 ¶
Float64 reads n, a number as written, as its nearest float64, as v1's Number.Float64 did.
Types ¶
This section is empty.