jsonstruct

package module
v0.0.0-...-e812efc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2025 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

Package jsonstruct derives the set of JSON fields for a Go struct type. It exposes the internal logic used by the encoding/json/v2 implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field struct {
	Index    []int        // index to the struct field according to [reflect.Type.FieldByIndex]
	GoType   reflect.Type // the Go type of the field
	JSONName string       // the JSON name of the field

	StrictCase bool   // whether `case:strict` is specified
	IgnoreCase bool   // whether `case:ignore` is specified
	Inline     bool   // whether `inline` is specified
	Unknown    bool   // whether `unknown` is specified
	OmitZero   bool   // whether `omitzero` is specified
	OmitEmpty  bool   // whether `omitempty` is specified
	String     bool   // whether `string` is specified
	Format     string // the `format` string value
}

Field is a JSON serializable Go struct field.

type Fields

type Fields struct {
	// ByIndex a list of all JSON serializable fields
	// in depth-first ordering.
	ByIndex []Field
	// ByName is a mapping of all JSON field names
	// to an index into ByIndex.
	ByName map[string]int
	// InlinedFallback is the field used to store unknown fields.
	// It is valid only if Field.Index is non-nil.
	InlinedFallback Field
}

Fields the set of all JSON serializable fields in a Go struct field.

func FieldsOf

func FieldsOf(t reflect.Type) (Fields, error)

FieldsOf derives the JSON serializable fields of a Go struct type t. The result must not be mutated.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL