Documentation
¶
Overview ¶
Package fields resolves JSON-v2 field visibility and reflection paths. It does not compile validation rules or mutate application data.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EscapePointer ¶
EscapePointer escapes a segment per RFC 6901.
func Marshals ¶
Marshals reports whether the type, or a pointer to it, customizes its JSON encoding. Such types are leaves: their fields are never promoted.
func Options ¶
Options splits the option suffix of a JSON-v2 field tag without interpreting commas inside single-quoted format strings as option boundaries. Backslash escapes protect the next character inside a quoted string. This only locates boundaries; the JSON encoder still owns tag validity and format interpretation. An empty suffix produces one empty, harmless option.
Types ¶
type Field ¶
type Field struct {
// GoName is the Go field selector accepted during registration.
GoName string
// JSONName is the encoded field name used in JSON Pointers and schema
// properties.
JSONName string
// Index is the reflection path through promoted fields to the selected value.
Index []int
// Type is the exact selected field type, including named-type identity.
Type reflect.Type
// contains filtered or unexported fields
}
Field describes one JSON-visible Go field selected by discovery. Its Go name selects registrations; its JSON name determines error pointers.
type Struct ¶
type Struct struct {
// Fields lists selected JSON-visible fields in Go declaration order.
Fields []*Field
// ByGo indexes selected fields by their Go selector for registration lookup.
ByGo map[string]*Field
// Rejected maps unavailable selectors to the reason registration must reject
// them.
Rejected map[string]string
}
Struct is the resolved field table of a struct type.
func Inspect ¶
Inspect resolves the JSON names of the fields of a struct type following the encoding/json/v2 rules. The caller caches the result.
func (*Struct) Lookup ¶
Lookup resolves a Go selector that is either a JSON-visible terminal field or an untagged embedded struct on an explicit path. Embedded containers have no JSON segment: their selected children retain their flattened JSON names. FieldByName enforces Go ambiguity and shortest-depth selection independently of JSON dominance, including selectors through unexported value embeddings.