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.
The stores in store/postgres, store/sqlite and store/redis import this package, and they are separate modules. A user can end up with this root module at a newer version than an older store module, so treat everything exported here as public API between Chronicle's own modules: add to it, but don't rename, remove or change the signature of anything an older store module might still call.
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.