json

package
v0.0.0-...-cdf09a4 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package json contains helper functions for encoding and decoding JSON.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeDate

func DecodeDate(i *jx.Decoder) (v time.Time, err error)

DecodeDate decodes date from json.

func DecodeDateTime

func DecodeDateTime(i *jx.Decoder) (v time.Time, err error)

DecodeDateTime decodes date-time from json.

func DecodeDuration

func DecodeDuration(i *jx.Decoder) (v time.Duration, err error)

DecodeDuration decodes duration from json.

func DecodeIP

func DecodeIP(d *jx.Decoder) (netip.Addr, error)

DecodeIP decodes netip.Addr.

func DecodeIPv4

func DecodeIPv4(d *jx.Decoder) (netip.Addr, error)

DecodeIPv4 decodes netip.Addr.

func DecodeIPv6

func DecodeIPv6(d *jx.Decoder) (netip.Addr, error)

DecodeIPv6 decodes netip.Addr.

func DecodeStringFloat32

func DecodeStringFloat32(d *jx.Decoder) (float32, error)

DecodeStringFloat32 decodes string float32 from json.

func DecodeStringFloat64

func DecodeStringFloat64(d *jx.Decoder) (float64, error)

DecodeStringFloat64 decodes string float64 from json.

func DecodeStringInt

func DecodeStringInt(d *jx.Decoder) (int, error)

DecodeStringInt decodes string int from json.

func DecodeStringInt16

func DecodeStringInt16(d *jx.Decoder) (int16, error)

DecodeStringInt16 decodes string int16 from json.

func DecodeStringInt32

func DecodeStringInt32(d *jx.Decoder) (int32, error)

DecodeStringInt32 decodes string int32 from json.

func DecodeStringInt64

func DecodeStringInt64(d *jx.Decoder) (int64, error)

DecodeStringInt64 decodes string int64 from json.

func DecodeStringInt8

func DecodeStringInt8(d *jx.Decoder) (int8, error)

DecodeStringInt8 decodes string int8 from json.

func DecodeStringUint

func DecodeStringUint(d *jx.Decoder) (uint, error)

DecodeStringUint decodes string int from json.

func DecodeStringUint16

func DecodeStringUint16(d *jx.Decoder) (uint16, error)

DecodeStringUint16 decodes string int16 from json.

func DecodeStringUint32

func DecodeStringUint32(d *jx.Decoder) (uint32, error)

DecodeStringUint32 decodes string int32 from json.

func DecodeStringUint64

func DecodeStringUint64(d *jx.Decoder) (uint64, error)

DecodeStringUint64 decodes string int64 from json.

func DecodeStringUint8

func DecodeStringUint8(d *jx.Decoder) (uint8, error)

DecodeStringUint8 decodes string int8 from json.

func DecodeStringUnixMicro

func DecodeStringUnixMicro(d *jx.Decoder) (time.Time, error)

DecodeStringUnixMicro decodes unix-micro from json string.

func DecodeStringUnixMilli

func DecodeStringUnixMilli(d *jx.Decoder) (time.Time, error)

DecodeStringUnixMilli decodes unix-milli from json string.

func DecodeStringUnixNano

func DecodeStringUnixNano(d *jx.Decoder) (time.Time, error)

DecodeStringUnixNano decodes unix-nano from json string.

func DecodeStringUnixSeconds

func DecodeStringUnixSeconds(d *jx.Decoder) (time.Time, error)

DecodeStringUnixSeconds decodes unix-seconds from json string.

func DecodeTime

func DecodeTime(i *jx.Decoder) (v time.Time, err error)

DecodeTime decodes time from json.

func DecodeURI

func DecodeURI(i *jx.Decoder) (v url.URL, err error)

DecodeURI decodes url.URL from json.

func DecodeUUID

func DecodeUUID(i *jx.Decoder) (v uuid.UUID, err error)

DecodeUUID decodes UUID from json.

func DecodeUnixMicro

func DecodeUnixMicro(d *jx.Decoder) (time.Time, error)

DecodeUnixMicro decodes unix-micro from json string.

func DecodeUnixMilli

func DecodeUnixMilli(d *jx.Decoder) (time.Time, error)

DecodeUnixMilli decodes unix-milli from json string.

func DecodeUnixNano

func DecodeUnixNano(d *jx.Decoder) (time.Time, error)

DecodeUnixNano decodes unix-nano from json string.

func DecodeUnixSeconds

func DecodeUnixSeconds(d *jx.Decoder) (time.Time, error)

DecodeUnixSeconds decodes unix-seconds from json string.

func Encode

func Encode(m Marshaler) []byte

Encode Marshaler to byte slice.

func EncodeDate

func EncodeDate(s *jx.Encoder, v time.Time)

EncodeDate encodes date to json.

func EncodeDateTime

func EncodeDateTime(s *jx.Encoder, v time.Time)

EncodeDateTime encodes date-time to json.

func EncodeDuration

func EncodeDuration(s *jx.Encoder, v time.Duration)

EncodeDuration encodes duration to json.

func EncodeIP

func EncodeIP(s *jx.Encoder, v netip.Addr)

EncodeIP encodes netip.Addr.

func EncodeIPv4

func EncodeIPv4(s *jx.Encoder, v netip.Addr)

EncodeIPv4 encodes netip.Addr.

func EncodeIPv6

func EncodeIPv6(s *jx.Encoder, v netip.Addr)

EncodeIPv6 encodes netip.Addr.

func EncodeStringFloat32

func EncodeStringFloat32(e *jx.Encoder, v float32)

EncodeStringFloat32 encodes string float32 to json.

func EncodeStringFloat64

func EncodeStringFloat64(e *jx.Encoder, v float64)

EncodeStringFloat64 encodes string float64 to json.

func EncodeStringInt

func EncodeStringInt(e *jx.Encoder, v int)

EncodeStringInt encodes string int to json.

func EncodeStringInt16

func EncodeStringInt16(e *jx.Encoder, v int16)

EncodeStringInt16 encodes string int16 to json.

func EncodeStringInt32

func EncodeStringInt32(e *jx.Encoder, v int32)

EncodeStringInt32 encodes string int32 to json.

func EncodeStringInt64

func EncodeStringInt64(e *jx.Encoder, v int64)

EncodeStringInt64 encodes string int64 to json.

func EncodeStringInt8

func EncodeStringInt8(e *jx.Encoder, v int8)

EncodeStringInt8 encodes string int8 to json.

func EncodeStringUint

func EncodeStringUint(e *jx.Encoder, v uint)

EncodeStringUint encodes string uint to json.

func EncodeStringUint16

func EncodeStringUint16(e *jx.Encoder, v uint16)

EncodeStringUint16 encodes string uint16 to json.

func EncodeStringUint32

func EncodeStringUint32(e *jx.Encoder, v uint32)

EncodeStringUint32 encodes string uint32 to json.

func EncodeStringUint64

func EncodeStringUint64(e *jx.Encoder, v uint64)

EncodeStringUint64 encodes string uint64 to json.

func EncodeStringUint8

func EncodeStringUint8(e *jx.Encoder, v uint8)

EncodeStringUint8 encodes string uint8 to json.

func EncodeStringUnixMicro

func EncodeStringUnixMicro(e *jx.Encoder, v time.Time)

EncodeStringUnixMicro encodes unix-micro to json string.

func EncodeStringUnixMilli

func EncodeStringUnixMilli(e *jx.Encoder, v time.Time)

EncodeStringUnixMilli encodes unix-milli to json string.

func EncodeStringUnixNano

func EncodeStringUnixNano(e *jx.Encoder, v time.Time)

EncodeStringUnixNano encodes unix-nano to json string.

func EncodeStringUnixSeconds

func EncodeStringUnixSeconds(e *jx.Encoder, v time.Time)

EncodeStringUnixSeconds encodes unix-seconds to json string.

func EncodeTime

func EncodeTime(s *jx.Encoder, v time.Time)

EncodeTime encodes time to json.

func EncodeURI

func EncodeURI(s *jx.Encoder, v url.URL)

EncodeURI encodes url.URL to json.

func EncodeUUID

func EncodeUUID(s *jx.Encoder, v uuid.UUID)

EncodeUUID encodes UUID to json.

func EncodeUnixMicro

func EncodeUnixMicro(e *jx.Encoder, v time.Time)

EncodeUnixMicro encodes unix-micro to json string.

func EncodeUnixMilli

func EncodeUnixMilli(e *jx.Encoder, v time.Time)

EncodeUnixMilli encodes unix-milli to json string.

func EncodeUnixNano

func EncodeUnixNano(e *jx.Encoder, v time.Time)

EncodeUnixNano encodes unix-nano to json string.

func EncodeUnixSeconds

func EncodeUnixSeconds(e *jx.Encoder, v time.Time)

EncodeUnixSeconds encodes unix-seconds to json string.

func Equal

func Equal(a, b []byte) (bool, error)

Equal compares two JSON values.

func Marshal

func Marshal(val any) ([]byte, error)

Marshal value to json.

func Unmarshal

func Unmarshal(data []byte, val any) error

Unmarshal value from json.

Types

type Marshaler

type Marshaler interface {
	Encode(e *jx.Encoder)
}

Marshaler implements json writing.

type Nullable

type Nullable interface {
	IsNil() bool
}

Nullable can be nil (but defined) or not.

type Resettable

type Resettable interface {
	Reset()
}

Resettable value can be unset.

type Settable

type Settable interface {
	IsSet() bool
}

Settable value can be set (present) or unset (i.e. not provided or undefined).

type Unmarshaler

type Unmarshaler interface {
	Decode(d *jx.Decoder) error
}

Unmarshaler implements json reading.

type Value

type Value interface {
	Marshaler
	Unmarshaler
}

Value represents a json value.

Jump to

Keyboard shortcuts

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