jsonutil

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: MIT Imports: 7 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadJSON added in v1.5.1

func LoadJSON[X any](inputPath string) (*X, error)

func LoadTOML added in v1.9.3

func LoadTOML[X any](inputPath string) (*X, error)

func MergeJSON added in v1.9.5

func MergeJSON[T any](in T, overrides ...map[string]any) (T, error)

MergeJSON merges the provided overrides into the input struct. Fields must be JSON-serializable for this to work. Overrides are applied in order of precedence - i.e., the last overrides will override keys from all preceding overrides.

func WriteJSON added in v1.5.0

func WriteJSON[X any](value X, target ioutil.OutputTarget) error

func WriteTOML added in v1.9.3

func WriteTOML[X any](value X, target ioutil.OutputTarget) error

Types

type Decoder added in v1.9.3

type Decoder interface {
	Decode(v interface{}) error
}

type DecoderFactory added in v1.9.3

type DecoderFactory func(r io.Reader) Decoder

type Encoder added in v1.9.3

type Encoder interface {
	Encode(v interface{}) error
}

type EncoderFactory added in v1.9.3

type EncoderFactory func(w io.Writer) Encoder

type LazySortedJsonMap

type LazySortedJsonMap[K comparable, V any] map[K]V

LazySortedJsonMap provides sorted encoding order for JSON maps. The sorting is lazy: in-memory it's just a map, until it sorts just-in-time when the map is encoded to JSON. Warning: the just-in-time sorting requires a full allocation of the map structure and keys slice during encoding. Sorting order is not enforced when decoding from JSON.

func (LazySortedJsonMap[K, V]) MarshalJSON

func (m LazySortedJsonMap[K, V]) MarshalJSON() ([]byte, error)

func (*LazySortedJsonMap[K, V]) UnmarshalJSON

func (m *LazySortedJsonMap[K, V]) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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