json

package module
v1.16.9 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: Apache-2.0 Imports: 15 Imported by: 40

README

JSON

In the above case, the JSON structure of addition type. It supports JSON interfaces in the standard library, adds object and array, and raw message supports mapping to object and array.

Install

go get github.com/aacfactory/json

Feature

  • Json Object
  • Time(RFC3339)
  • Date
  • Complex
  • Json Array
  • Json Raw
  • Fast

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EmptyArrayBytes = []byte{'[', ']'}
)
View Source
var (
	EmptyObjectBytes = []byte{'{', '}'}
)
View Source
var (
	NullBytes = []byte("null")
)

Functions

func Config added in v1.16.1

func Config(config jsoniter.Config)

func ConfigCompatibleWithStandardLibrary added in v1.16.1

func ConfigCompatibleWithStandardLibrary()

func Default added in v1.14.0

func Default() jsoniter.API

func IsEmptyArray added in v1.15.0

func IsEmptyArray(p []byte) (ok bool)

func IsEmptyObject added in v1.15.0

func IsEmptyObject(p []byte) (ok bool)

func IsNull added in v1.15.0

func IsNull(p []byte) (ok bool)

func Marshal

func Marshal(v interface{}) (p []byte, err error)

func Shorted added in v1.14.0

func Shorted() jsoniter.API

func Unmarshal

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

func UnsafeMarshal

func UnsafeMarshal(v interface{}) []byte

func UnsafeUnmarshal

func UnsafeUnmarshal(data []byte, v interface{})

func Validate

func Validate(data []byte) bool

func ValidateString

func ValidateString(data string) bool

Types

type Array

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

func NewArray

func NewArray() *Array

func NewArrayFromBytes

func NewArrayFromBytes(b []byte) *Array

func (*Array) Add

func (array *Array) Add(values ...interface{}) (err error)

func (*Array) Empty

func (array *Array) Empty() (ok bool)

func (*Array) Get

func (array *Array) Get(i int, v interface{}) (err error)

func (*Array) Len

func (array *Array) Len() (size int)

func (*Array) MapTo

func (array *Array) MapTo(v interface{}) (err error)

func (*Array) MarshalJSON

func (array *Array) MarshalJSON() (p []byte, err error)

func (*Array) Raw

func (array *Array) Raw() (raw []byte)

func (*Array) Remove

func (array *Array) Remove(i int) (err error)

func (*Array) UnmarshalJSON

func (array *Array) UnmarshalJSON(p []byte) (err error)

func (*Array) WriteTo added in v1.2.0

func (array *Array) WriteTo(out *Array) (err error)

type Date added in v1.4.0

type Date struct {
	Year  int
	Month time.Month
	Day   int
}

func DateNow added in v1.6.0

func DateNow() Date

func DateOf added in v1.16.1

func DateOf(t time.Time) Date

func NewDate added in v1.4.0

func NewDate(year int, month time.Month, day int) Date

func (Date) IsZero added in v1.12.1

func (d Date) IsZero() (ok bool)

func (Date) String added in v1.4.0

func (d Date) String() string

func (Date) ToTime added in v1.4.0

func (d Date) ToTime() time.Time

type Marshaler

type Marshaler interface {
	MarshalJSON() ([]byte, error)
}

type Object

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

func NewObject

func NewObject() *Object

func NewObjectFromBytes

func NewObjectFromBytes(b []byte) *Object

func NewObjectFromInterface

func NewObjectFromInterface(v interface{}) *Object

func (*Object) Contains

func (object *Object) Contains(path string) (has bool)

func (*Object) Empty

func (object *Object) Empty() (ok bool)

func (*Object) Get

func (object *Object) Get(path string, v interface{}) (err error)

func (*Object) MapTo

func (object *Object) MapTo(v interface{}) (err error)

func (*Object) MarshalJSON

func (object *Object) MarshalJSON() (p []byte, err error)

func (*Object) Merge added in v1.2.0

func (object *Object) Merge(src *Object) (err error)

func (*Object) Put

func (object *Object) Put(path string, v interface{}) (err error)

func (*Object) PutRaw

func (object *Object) PutRaw(path string, raw []byte) (err error)

func (*Object) Raw

func (object *Object) Raw() (raw []byte)

func (*Object) Remove

func (object *Object) Remove(path string) (err error)

func (*Object) UnmarshalJSON

func (object *Object) UnmarshalJSON(p []byte) (err error)

func (*Object) WriteTo added in v1.2.0

func (object *Object) WriteTo(out *Object) (err error)

type RawMessage added in v1.1.0

type RawMessage []byte

func (RawMessage) MapToArray added in v1.1.0

func (m RawMessage) MapToArray() (r *Array, err error)

func (RawMessage) MapToObject added in v1.1.0

func (m RawMessage) MapToObject() (r *Object, err error)

func (RawMessage) Marshal added in v1.16.6

func (m RawMessage) Marshal() (p []byte, err error)

Marshal objects.Marshal

func (RawMessage) MarshalBinary added in v1.4.3

func (m RawMessage) MarshalBinary() (data []byte, err error)

func (RawMessage) MarshalJSON added in v1.1.0

func (m RawMessage) MarshalJSON() ([]byte, error)

func (*RawMessage) Scan added in v1.16.0

func (m *RawMessage) Scan(src interface{}) (err error)

Scan sql.Scanner

func (RawMessage) TryMapToArray added in v1.1.0

func (m RawMessage) TryMapToArray() bool

func (RawMessage) TryMapToObject added in v1.1.0

func (m RawMessage) TryMapToObject() bool

func (RawMessage) Unmarshal added in v1.16.6

func (m RawMessage) Unmarshal(dst interface{}) (err error)

Unmarshal objects.Unmarshal

func (*RawMessage) UnmarshalBinary added in v1.4.3

func (m *RawMessage) UnmarshalBinary(data []byte) (err error)

func (*RawMessage) UnmarshalJSON added in v1.1.0

func (m *RawMessage) UnmarshalJSON(data []byte) error

func (RawMessage) Valid added in v1.16.2

func (m RawMessage) Valid() (ok bool)

Valid objects.Valid

func (RawMessage) Value added in v1.16.6

func (m RawMessage) Value() (v any)

Value objects.Value

type Time added in v1.4.0

type Time struct {
	Hour    int
	Minutes int
	Second  int
}

func NewTime added in v1.6.0

func NewTime(hour int, minutes int, second int) Time

func TimeOf added in v1.16.1

func TimeOf(t time.Time) Time

func (Time) IsZero added in v1.13.0

func (t Time) IsZero() (ok bool)

func (Time) String added in v1.4.0

func (t Time) String() string

func (Time) ToTime added in v1.6.0

func (t Time) ToTime() time.Time

type Unmarshaler

type Unmarshaler interface {
	UnmarshalJSON([]byte) error
}

Jump to

Keyboard shortcuts

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