apijson

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: MPL-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

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

Marshals the given data to a JSON string. For null values, omits the property entirely.

func MarshalForUpdate

func MarshalForUpdate(plan interface{}, state interface{}) ([]byte, error)

Marshals the given plan data to a JSON string. For null values, omits the property unless the corresponding state value was set.

func MarshalRoot

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

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 UnmarshalComputed

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

UnmarshalComputed is similar to Unmarshal, but leaves non-computed properties (e.g. required and optional) unchanged.

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 TerraformUpdateBehavior

type TerraformUpdateBehavior int
const (
	// always update the property from JSON
	Always TerraformUpdateBehavior = iota

	// if the value is Null or Undefined, then update the value, otherwise skip
	IfUnset

	// always leave this property unchanged, but possibly update nested values
	OnlyNested
)

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