apijson

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(value interface{}) ([]byte, error)

func MarshalRoot

func MarshalRoot(value interface{}) ([]byte, error)

func Port

func Port(from any, to any) error

Port copies over values from one struct to another struct.

func RegisterUnion

func RegisterUnion(typ reflect.Type, discriminator string, variants ...UnionVariant)

func Unmarshal

func Unmarshal(raw []byte, to any) error

Unmarshal is similar to encoding/json.Unmarshal and parses the JSON-encoded data and stores it in the given pointer.

func UnmarshalRoot

func UnmarshalRoot(raw []byte, to any) error

UnmarshalRoot is like Unmarshal, but doesn't try to call MarshalJSON on the root element. Useful if a struct's UnmarshalJSON is overrode to use the behavior of this encoder versus the standard library.

Types

type Field

type Field struct {
	// contains filtered or unexported fields
}

func (Field) IsInvalid

func (j Field) IsInvalid() bool

func (Field) IsMissing

func (j Field) IsMissing() bool

func (Field) IsNull

func (j Field) IsNull() bool

Returns true if the field is explicitly `null` _or_ if it is not present at all (ie, missing). To check if the field's key is present in the JSON with an explicit null value, you must check `f.IsNull() && !f.IsMissing()`.

func (Field) Raw

func (j Field) Raw() string

type UnionVariant

type UnionVariant struct {
	TypeFilter         gjson.Type
	DiscriminatorValue interface{}
	Type               reflect.Type
}

Jump to

Keyboard shortcuts

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