json

package
v0.42.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2022 License: Apache-2.0 Imports: 12 Imported by: 74

Documentation

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(i *jx.Decoder) (v netip.Addr, err error)

DecodeIP decodes netip.Addr.

func DecodeStringInt32 added in v0.29.0

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

DecodeStringInt32 decodes string int32 from json.

func DecodeStringInt64 added in v0.29.0

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

DecodeStringInt64 decodes string int64 from json.

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 added in v0.30.0

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

DecodeUnixMicro decodes unix-micro from json.

func DecodeUnixMilli added in v0.30.0

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

DecodeUnixMilli decodes unix-milli from json.

func DecodeUnixNano added in v0.30.0

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

DecodeUnixNano decodes unix-nano from json.

func DecodeUnixSeconds added in v0.30.0

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

DecodeUnixSeconds decodes unix-seconds from json.

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 EncodeStringInt32 added in v0.29.0

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

EncodeStringInt32 encodes string int32 to json.

func EncodeStringInt64 added in v0.29.0

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

EncodeStringInt64 encodes string int64 to json.

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 added in v0.30.0

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

EncodeUnixMicro encodes unix-micro to json.

func EncodeUnixMilli added in v0.30.0

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

EncodeUnixMilli encodes unix-milli to json.

func EncodeUnixNano added in v0.30.0

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

EncodeUnixNano encodes unix-nano to json.

func EncodeUnixSeconds added in v0.30.0

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

EncodeUnixSeconds encodes unix-seconds to json.

func Equal added in v0.34.0

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

Equal compares two JSON values.

func LineColumn added in v0.42.0

func LineColumn(offset int64, data []byte) (line, column int64, ok bool)

LineColumn returns the line and column of the location.

If offset is invalid, line and column are 0 and ok is false.

func LocationUnmarshaler added in v0.42.0

func LocationUnmarshaler(data []byte) *json.Unmarshalers

LocationUnmarshaler is json.Unmarshalers that sets the location.

func Marshal

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

Marshal value to json.

func Unmarshal

func Unmarshal(data []byte, val interface{}) error

Unmarshal value from json.

Types

type Locatable added in v0.42.0

type Locatable interface {
	Location() (Location, bool)
	// contains filtered or unexported methods
}

Locatable is an interface for JSON value location store.

type Location added in v0.42.0

type Location struct {
	JSONPointer  string `json:"-"`
	Offset       int64  `json:"-"`
	Line, Column int64  `json:"-"`
}

Location is a JSON value location.

func (Location) String added in v0.42.0

func (l Location) String() string

String implements fmt.Stringer.

type Locator added in v0.42.0

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

Locator stores the Location of a JSON value.

func (Locator) Location added in v0.42.0

func (l Locator) Location() (Location, bool)

Location returns the location of the value if it is set.

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