Documentation
¶
Overview ¶
Package jsonobject normalizes stored JSON object documents.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalid = errors.New("value must be exactly one JSON object")
ErrInvalid reports a value that is not exactly one JSON object.
Functions ¶
func Normalize ¶
func Normalize(raw json.RawMessage) (json.RawMessage, error)
Normalize returns one stable encoding of a JSON object: an empty value becomes {}, members are sorted by name, insignificant whitespace is removed and numbers keep their literal text. Anything other than a single object, including null and trailing values, fails with ErrInvalid.
Objects with the same members and number literals therefore encode identically, which stored snapshots and retry identities rely on. It is not a general canonical JSON form: strings keep encoding/json's escaping, numbers are not rewritten (1 and 1.0 differ) and a repeated member keeps its last value.
Types ¶
This section is empty.