json

package
v0.0.0-...-157c9c8 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Deserialize

func Deserialize(i any, r io.Reader) error

Deserialize wraps encoding/json Decoder to fulfill type32.DeserializeTypeID32Funcn

func Serialize

func Serialize(i any, w io.Writer) error

Serialize wraps encoding/json Encoder to fulfill type32.SerializeTypeID32Func

Types

type Deserializer

type Deserializer struct{}

Deserializer fulfill serial.Deserializer.

func (Deserializer) Deserialize

func (Deserializer) Deserialize(v any, data []byte) error

Deserialize the JSON data into v. This fulfills fulfill serial.Deserializer.

func (Deserializer) Load

func (d Deserializer) Load(v any, path string) error

Load reads the JSON data from the file at the path location and deserializes it to v.

func (Deserializer) ReadFrom

func (Deserializer) ReadFrom(v any, r io.Reader) error

ReadFrom read JSON data from r and deserializes it into v.

type Serializer

type Serializer struct {
	Prefix, Indent string
}

Serializer holds options for serializing json.

func NewSerializer

func NewSerializer(prefix, indent string) Serializer

NewSerializer with options

func (Serializer) Save

func (s Serializer) Save(v any, path string) error

Save writes the JSON value of v to the file at the path location.

func (Serializer) Serialize

func (s Serializer) Serialize(v any, buf []byte) ([]byte, error)

Serialize writes the JSON value of v to a byte slice. It will use buf if there is enough room.

func (Serializer) WriteTo

func (s Serializer) WriteTo(v any, w io.Writer) error

WriteTo fulfills io.WriterTo. It writes the JSON value of v to w.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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