Documentation
¶
Overview ¶
Package jsonline decodes and encodes the JSON objects of a native session log so that an object read and written again is the same JSON value: members the Go type does not declare are kept, and a declared member that was absent stays absent, a null stays null. The format packages embed Members in every type they decode. It imports the standard library alone, as the format packages must.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decode ¶
Decode unmarshals data into v, a pointer to a struct type without its own UnmarshalJSON, and fills m from the members data carries.
func DecodeLenient ¶
DecodeLenient is Decode for a type that is a union of several shapes, where one shape's member may share a name with another's of a different JSON type: when the object does not decode whole, each declared member is decoded alone, and one whose value does not fit its field is kept in Extra, written back as it was, and listed by Members.Mistyped. It fails only when data is not a JSON object.
Types ¶
type Members ¶
type Members struct {
// Extra holds the members the type does not declare, verbatim.
Extra map[string]json.RawMessage `json:"-"`
// contains filtered or unexported fields
}
Members is embedded in every object a format package decodes. It keeps the members the Go type does not declare, and remembers which declared members the input carried and which were null, so an object decoded and encoded again is the same JSON value: a member absent from the input stays absent, an explicit false or zero stays, and a null stays null.
func (*Members) Has ¶
Has reports whether the input carried the declared member name, null or not. An object built in Go rather than decoded reports false.
func (*Members) Mistyped ¶
Mistyped lists the declared members DecodeLenient found holding a value of another JSON type, which it kept in Extra instead, sorted.