Documentation
¶
Overview ¶
Package jsonfields finds the JSON object members of a Go struct by the rules of encoding/json/v2: the fields which a value of the struct is marshaled to and unmarshaled from, with the options of their `json` tags.
A Go struct is a list of fields found by a breadth-first search over its fields and the fields of the structs embedded in it. A field hides the fields of the same name deeper than it, and of two fields at the same depth the one whose name is given by its tag. An error in the definition of the struct is reported when a value of it is marshaled or unmarshaled, not when the type is seen: an empty map of it is still {}.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // RawValueType is jsontext.Value, which is an embedded fallback. RawValueType reflect.Type // MethodTypes are the interfaces of the methods of marshaling and unmarshaling: a type which has one of them // can't be embedded. MethodTypes []reflect.Type )
The types which the json packages give this package: the ones it can't import.
Functions ¶
Types ¶
type Casing ¶
type Casing int8
Casing is how the name of a field is matched when unmarshaling, by its `case` option.
type Field ¶
type Field struct {
Options
// Index is the index of the field by reflect.Type.FieldByIndex: the fields of the embedded structs on the
// way to it, and the field.
Index []int
Type reflect.Type
// ID is the place of the field in the breadth-first order of the fields.
ID int
// HasIsZero is whether the type of the field, or the pointer to it, has the IsZero method, which decides
// whether the field is omitted by omitzero.
HasIsZero bool
}
Field is a JSON object member of a struct.
type Fields ¶
type Fields struct {
// List is the fields in the depth-first order of their indexes, which is the order they are marshaled in.
List []Field
// Fallback is the embedded field of a map or of jsontext.Value which holds the members of no other field, or
// nil.
Fallback *Field
// Err is the first error of the definition of the struct, or nil.
Err *Error
// FormatErr is the error of the first field with the `format` option, which encoding/json/v2 doesn't
// support, or nil.
FormatErr *Error
}
Fields are the JSON object members of a struct.