Documentation ¶
Overview ¶
Package json contains helper functions for encoding and decoding JSON.
Index ¶
- func DecodeDate(d *jx.Decoder) (v time.Time, err error)
- func DecodeDateTime(d *jx.Decoder) (v time.Time, err error)
- func DecodeDuration(d *jx.Decoder) (v time.Duration, err error)
- func DecodeIP(d *jx.Decoder) (netip.Addr, error)
- func DecodeIPv4(d *jx.Decoder) (netip.Addr, error)
- func DecodeIPv6(d *jx.Decoder) (netip.Addr, error)
- func DecodeMAC(d *jx.Decoder) (net.HardwareAddr, error)
- func DecodeStringFloat32(d *jx.Decoder) (float32, error)
- func DecodeStringFloat64(d *jx.Decoder) (float64, error)
- func DecodeStringInt(d *jx.Decoder) (int, error)
- func DecodeStringInt16(d *jx.Decoder) (int16, error)
- func DecodeStringInt32(d *jx.Decoder) (int32, error)
- func DecodeStringInt64(d *jx.Decoder) (int64, error)
- func DecodeStringInt8(d *jx.Decoder) (int8, error)
- func DecodeStringUint(d *jx.Decoder) (uint, error)
- func DecodeStringUint16(d *jx.Decoder) (uint16, error)
- func DecodeStringUint32(d *jx.Decoder) (uint32, error)
- func DecodeStringUint64(d *jx.Decoder) (uint64, error)
- func DecodeStringUint8(d *jx.Decoder) (uint8, error)
- func DecodeStringUnixMicro(d *jx.Decoder) (time.Time, error)
- func DecodeStringUnixMilli(d *jx.Decoder) (time.Time, error)
- func DecodeStringUnixNano(d *jx.Decoder) (time.Time, error)
- func DecodeStringUnixSeconds(d *jx.Decoder) (time.Time, error)
- func DecodeTime(d *jx.Decoder) (v time.Time, err error)
- func DecodeTimeFormat(d *jx.Decoder, layout string) (v time.Time, err error)
- func DecodeURI(i *jx.Decoder) (v url.URL, err error)
- func DecodeUUID(i *jx.Decoder) (v uuid.UUID, err error)
- func DecodeUnixMicro(d *jx.Decoder) (time.Time, error)
- func DecodeUnixMilli(d *jx.Decoder) (time.Time, error)
- func DecodeUnixNano(d *jx.Decoder) (time.Time, error)
- func DecodeUnixSeconds(d *jx.Decoder) (time.Time, error)
- func Encode(m Marshaler) []byte
- func EncodeDate(e *jx.Encoder, v time.Time)
- func EncodeDateTime(e *jx.Encoder, v time.Time)
- func EncodeDuration(e *jx.Encoder, v time.Duration)
- func EncodeIP(s *jx.Encoder, v netip.Addr)
- func EncodeIPv4(s *jx.Encoder, v netip.Addr)
- func EncodeIPv6(s *jx.Encoder, v netip.Addr)
- func EncodeMAC(e *jx.Encoder, v net.HardwareAddr)
- func EncodeStringFloat32(e *jx.Encoder, v float32)
- func EncodeStringFloat64(e *jx.Encoder, v float64)
- func EncodeStringInt(e *jx.Encoder, v int)
- func EncodeStringInt16(e *jx.Encoder, v int16)
- func EncodeStringInt32(e *jx.Encoder, v int32)
- func EncodeStringInt64(e *jx.Encoder, v int64)
- func EncodeStringInt8(e *jx.Encoder, v int8)
- func EncodeStringUint(e *jx.Encoder, v uint)
- func EncodeStringUint16(e *jx.Encoder, v uint16)
- func EncodeStringUint32(e *jx.Encoder, v uint32)
- func EncodeStringUint64(e *jx.Encoder, v uint64)
- func EncodeStringUint8(e *jx.Encoder, v uint8)
- func EncodeStringUnixMicro(e *jx.Encoder, v time.Time)
- func EncodeStringUnixMilli(e *jx.Encoder, v time.Time)
- func EncodeStringUnixNano(e *jx.Encoder, v time.Time)
- func EncodeStringUnixSeconds(e *jx.Encoder, v time.Time)
- func EncodeTime(e *jx.Encoder, v time.Time)
- func EncodeTimeFormat(e *jx.Encoder, v time.Time, layout string)
- func EncodeURI(s *jx.Encoder, v url.URL)
- func EncodeUUID(s *jx.Encoder, v uuid.UUID)
- func EncodeUnixMicro(e *jx.Encoder, v time.Time)
- func EncodeUnixMilli(e *jx.Encoder, v time.Time)
- func EncodeUnixNano(e *jx.Encoder, v time.Time)
- func EncodeUnixSeconds(e *jx.Encoder, v time.Time)
- func Equal(a, b []byte) (bool, error)
- func Marshal(val any) ([]byte, error)
- func NewTimeDecoder(layout string) func(i *jx.Decoder) (time.Time, error)
- func NewTimeEncoder(layout string) func(e *jx.Encoder, v time.Time)
- func Unmarshal(data []byte, val any) error
- type Marshaler
- type Nullable
- type Resettable
- type Settable
- type Unmarshaler
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeDate ¶
DecodeDate decodes date from json.
func DecodeDateTime ¶
DecodeDateTime decodes date-time from json.
func DecodeDuration ¶
DecodeDuration decodes duration from json.
func DecodeIPv4 ¶ added in v0.55.0
DecodeIPv4 decodes netip.Addr.
func DecodeIPv6 ¶ added in v0.55.0
DecodeIPv6 decodes netip.Addr.
func DecodeMAC ¶ added in v0.82.0
func DecodeMAC(d *jx.Decoder) (net.HardwareAddr, error)
DecodeMAC decodes net.HardwareAddr.
func DecodeStringFloat32 ¶ added in v0.70.0
DecodeStringFloat32 decodes string float32 from json.
func DecodeStringFloat64 ¶ added in v0.70.0
DecodeStringFloat64 decodes string float64 from json.
func DecodeStringInt ¶ added in v0.70.0
DecodeStringInt decodes string int from json.
func DecodeStringInt16 ¶ added in v0.70.0
DecodeStringInt16 decodes string int16 from json.
func DecodeStringInt32 ¶ added in v0.29.0
DecodeStringInt32 decodes string int32 from json.
func DecodeStringInt64 ¶ added in v0.29.0
DecodeStringInt64 decodes string int64 from json.
func DecodeStringInt8 ¶ added in v0.70.0
DecodeStringInt8 decodes string int8 from json.
func DecodeStringUint ¶ added in v0.70.0
DecodeStringUint decodes string int from json.
func DecodeStringUint16 ¶ added in v0.70.0
DecodeStringUint16 decodes string int16 from json.
func DecodeStringUint32 ¶ added in v0.70.0
DecodeStringUint32 decodes string int32 from json.
func DecodeStringUint64 ¶ added in v0.70.0
DecodeStringUint64 decodes string int64 from json.
func DecodeStringUint8 ¶ added in v0.70.0
DecodeStringUint8 decodes string int8 from json.
func DecodeStringUnixMicro ¶ added in v0.46.1
DecodeStringUnixMicro decodes unix-micro from json string.
func DecodeStringUnixMilli ¶ added in v0.46.1
DecodeStringUnixMilli decodes unix-milli from json string.
func DecodeStringUnixNano ¶ added in v0.46.1
DecodeStringUnixNano decodes unix-nano from json string.
func DecodeStringUnixSeconds ¶ added in v0.46.1
DecodeStringUnixSeconds decodes unix-seconds from json string.
func DecodeTime ¶
DecodeTime decodes time from json.
func DecodeTimeFormat ¶ added in v1.6.0
DecodeTimeFormat decodes date, time & date-time from json using a custom layout.
func DecodeUUID ¶
DecodeUUID decodes UUID from json.
func DecodeUnixMicro ¶ added in v0.30.0
DecodeUnixMicro decodes unix-micro from json string.
func DecodeUnixMilli ¶ added in v0.30.0
DecodeUnixMilli decodes unix-milli from json string.
func DecodeUnixNano ¶ added in v0.30.0
DecodeUnixNano decodes unix-nano from json string.
func DecodeUnixSeconds ¶ added in v0.30.0
DecodeUnixSeconds decodes unix-seconds from json string.
func EncodeDateTime ¶
EncodeDateTime encodes date-time to json.
func EncodeDuration ¶
EncodeDuration encodes duration to json.
func EncodeIPv4 ¶ added in v0.55.0
EncodeIPv4 encodes netip.Addr.
func EncodeIPv6 ¶ added in v0.55.0
EncodeIPv6 encodes netip.Addr.
func EncodeMAC ¶ added in v0.82.0
func EncodeMAC(e *jx.Encoder, v net.HardwareAddr)
EncodeMAC encodes net.HardwareAddr.
func EncodeStringFloat32 ¶ added in v0.70.0
EncodeStringFloat32 encodes string float32 to json.
func EncodeStringFloat64 ¶ added in v0.70.0
EncodeStringFloat64 encodes string float64 to json.
func EncodeStringInt ¶ added in v0.70.0
EncodeStringInt encodes string int to json.
func EncodeStringInt16 ¶ added in v0.70.0
EncodeStringInt16 encodes string int16 to json.
func EncodeStringInt32 ¶ added in v0.29.0
EncodeStringInt32 encodes string int32 to json.
func EncodeStringInt64 ¶ added in v0.29.0
EncodeStringInt64 encodes string int64 to json.
func EncodeStringInt8 ¶ added in v0.70.0
EncodeStringInt8 encodes string int8 to json.
func EncodeStringUint ¶ added in v0.70.0
EncodeStringUint encodes string uint to json.
func EncodeStringUint16 ¶ added in v0.70.0
EncodeStringUint16 encodes string uint16 to json.
func EncodeStringUint32 ¶ added in v0.70.0
EncodeStringUint32 encodes string uint32 to json.
func EncodeStringUint64 ¶ added in v0.70.0
EncodeStringUint64 encodes string uint64 to json.
func EncodeStringUint8 ¶ added in v0.70.0
EncodeStringUint8 encodes string uint8 to json.
func EncodeStringUnixMicro ¶ added in v0.46.1
EncodeStringUnixMicro encodes unix-micro to json string.
func EncodeStringUnixMilli ¶ added in v0.46.1
EncodeStringUnixMilli encodes unix-milli to json string.
func EncodeStringUnixNano ¶ added in v0.46.1
EncodeStringUnixNano encodes unix-nano to json string.
func EncodeStringUnixSeconds ¶ added in v0.46.1
EncodeStringUnixSeconds encodes unix-seconds to json string.
func EncodeTimeFormat ¶ added in v1.6.0
EncodeTimeFormat encodes date, time & date-time to json using a custom layout.
func EncodeUnixMicro ¶ added in v0.30.0
EncodeUnixMicro encodes unix-micro to json string.
func EncodeUnixMilli ¶ added in v0.30.0
EncodeUnixMilli encodes unix-milli to json string.
func EncodeUnixNano ¶ added in v0.30.0
EncodeUnixNano encodes unix-nano to json string.
func EncodeUnixSeconds ¶ added in v0.30.0
EncodeUnixSeconds encodes unix-seconds to json string.
func NewTimeDecoder ¶ added in v1.6.0
NewTimeDecoder returns a new time decoder using a custom layout.
func NewTimeEncoder ¶ added in v1.6.0
NewTimeEncoder returns a new time encoder using a custom layout.
Types ¶
type Settable ¶
type Settable interface {
IsSet() bool
}
Settable value can be set (present) or unset (i.e. not provided or undefined).
type Unmarshaler ¶
Unmarshaler implements json reading.