json

package
v3.15.0+incompatible Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalJSON

func MarshalJSON(anyObject interface{}) string

Gets the JSON

This method would panic if the JSON cannot be marshalled

func MarshalPrettyJSON

func MarshalPrettyJSON(anyObject interface{}) string

Gets the JSON(pretty)

This method would panic if the JSON cannot be marshalled

func UnmarshalToJson

func UnmarshalToJson(v interface{}) *sjson.Json

Types

type Bytes16

type Bytes16 types.Bytes16

func (*Bytes16) IsZero

func (b *Bytes16) IsZero() bool

func (Bytes16) MarshalJSON

func (b Bytes16) MarshalJSON() ([]byte, error)

For empty bytes, the value of base64 would be "AAAAAAAAAAAAAAAAAAAAAA=="

func (*Bytes16) UnmarshalJSON

func (b *Bytes16) UnmarshalJSON(v []byte) error

For empty string or "null" of JSON, the value of byte array[16] would be [16]byte{}

type IP

type IP net.IP

This type of time would be serialized to UNIX time for MarshalJSON()

func NewIP

func NewIP(s string) IP

func (IP) MarshalJSON

func (ip IP) MarshalJSON() ([]byte, error)

func (IP) String

func (ip IP) String() string

func (*IP) UnmarshalJSON

func (ip *IP) UnmarshalJSON(data []byte) error

UnmarshalJSON parses the JSON-encoded IP string

func (IP) Value

func (ip IP) Value() (driver.Value, error)

type JsonExt

type JsonExt struct {
	*sjson.Json
}

func ToJsonExt

func ToJsonExt(sjson *sjson.Json) *JsonExt

func UnmarshalToJsonExt

func UnmarshalToJsonExt(v interface{}) *JsonExt

func (*JsonExt) CheckGetExt

func (j *JsonExt) CheckGetExt(key string) (*JsonExt, bool)

func (*JsonExt) GetExt

func (j *JsonExt) GetExt(key string) *JsonExt

func (*JsonExt) GetIndexExt

func (j *JsonExt) GetIndexExt(index int) *JsonExt

func (*JsonExt) GetPathExt

func (j *JsonExt) GetPathExt(branch ...string) *JsonExt

func (*JsonExt) IsNil

func (j *JsonExt) IsNil() bool

func (*JsonExt) MustInt16

func (j *JsonExt) MustInt16() int16

func (*JsonExt) MustInt32

func (j *JsonExt) MustInt32() int32

func (*JsonExt) MustInt8

func (j *JsonExt) MustInt8() int8

func (*JsonExt) MustStringPtr

func (j *JsonExt) MustStringPtr() *string

func (*JsonExt) MustUint16

func (j *JsonExt) MustUint16() uint16

func (*JsonExt) MustUint32

func (j *JsonExt) MustUint32() uint32

func (*JsonExt) MustUint8

func (j *JsonExt) MustUint8() uint8

type JsonString

type JsonString string

When marshalling, the empty string would be "null" in JSON format

func (JsonString) MarshalJSON

func (s JsonString) MarshalJSON() ([]byte, error)

type JsonTime

type JsonTime time.Time

This type of time would be serialized to UNIX time for MarshalJSON()

func (JsonTime) MarshalJSON

func (t JsonTime) MarshalJSON() ([]byte, error)

MarshalJSON does the serialization of UNIX timestamp

func (JsonTime) String

func (t JsonTime) String() string

func (*JsonTime) UnmarshalJSON

func (t *JsonTime) UnmarshalJSON(data []byte) error

UnmarshalJSON does the deserialization of UNIX timestamp

func (JsonTime) Value

func (t JsonTime) Value() (driver.Value, error)

type RawJsonForm

type RawJsonForm string

When marshalling, the string would be the raw form of JSON format

func (RawJsonForm) MarshalJSON

func (s RawJsonForm) MarshalJSON() ([]byte, error)

type SimpleJsonMarshaler

type SimpleJsonMarshaler interface {
	MarshalSimpleJSON() (*sjson.Json, error)
}

type SimpleJsonUnmarshaler

type SimpleJsonUnmarshaler interface {
	UnmarshalSimpleJSON(*sjson.Json) error
}

type Uuid

type Uuid uuid.UUID

func (Uuid) MarshalJSON

func (u Uuid) MarshalJSON() ([]byte, error)

For uuid.Nil, the JSON value would be "null"

func (Uuid) ToUuid

func (u Uuid) ToUuid() uuid.UUID

func (*Uuid) UnmarshalJSON

func (u *Uuid) UnmarshalJSON(v []byte) error

For empty string or "null" value, the value of uuid would be uuid.Nil

type VarBytes

type VarBytes types.VarBytes

func (*VarBytes) MarshalJSON

func (b *VarBytes) MarshalJSON() ([]byte, error)

For nil slice and empty slice, the value of JSON would be "null"

func (*VarBytes) UnmarshalJSON

func (b *VarBytes) UnmarshalJSON(v []byte) error

For empty string or "null" of JSON, the value of byte slice would be []byte(nil)

Jump to

Keyboard shortcuts

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