Documentation
¶
Overview ¶
Package metajson decodes stored event metadata without losing numbers.
The event digest covers the JSON encoding of Metadata, so whatever a store reads back has to encode to the same bytes Record hashed. encoding/json turns every number into float64 by default, and float64 holds integers exactly only up to 2^53. Past that, 9007199254740993 comes back as 9007199254740992 and the event fails verification the moment it is read.
Decoding with UseNumber alone is not the answer either. PostgreSQL's jsonb rewrites numbers on the way in (1e-07 is returned as 0.0000001), and those only round-trip today because float64 formats them back the way Go first wrote them. So a number stays float64 whenever float64 holds it exactly, which also keeps the type callers already get for small values, and only an integer float64 would round becomes int64 or uint64.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Map ¶
Map is metadata that decodes through Decode. Stores use it as the model field type where a driver or encoding/json does the unmarshalling for them.
func (*Map) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.