xjson

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2020 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(data interface{}) (interface{}, error)

解析json数据为interface{}

func DecodeTo

func DecodeTo(data interface{}, v interface{}) error

解析json数据为指定格式

func Encode

func Encode(value interface{}) ([]byte, error)

编码为json数据

func JsonFormat

func JsonFormat(val interface{}) interface{}

func JsonQuotes

func JsonQuotes() string

json键值使用的引号

func MakeJsonKey

func MakeJsonKey(key string) string

由key生成符合json键名格式的字符串

func RegJsonFormatter

func RegJsonFormatter(vt reflect.Type, formatter JsonDataFormatter)

func Valid

func Valid(data interface{}) bool

检查data是否是json数据类型

Types

type JsonDataFormatter

type JsonDataFormatter interface {
	Format(v interface{}) interface{}
}

json序列化接口

type JsonStr

type JsonStr string

func (JsonStr) MarshalJSON

func (js JsonStr) MarshalJSON() (data []byte, err error)

func (JsonStr) String

func (js JsonStr) String() string

func (*JsonStr) UnmarshalJSON

func (js *JsonStr) UnmarshalJSON(data []byte) (err error)

type TJson

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

func DecodeToJson

func DecodeToJson(data interface{}, unsafe ...bool) (*TJson, error)

解码json数据为TJson对象实例

func Load

func Load(path string, unsafe ...bool) (*TJson, error)

文件加载json数据并转换为TJson对象实例 文件支持json,xml, toml,yaml格式

func LoadContent

func LoadContent(data interface{}, unsafe ...bool) (*TJson, error)

将其他数据加载转换成TJson对象实例

func LoadJson

func LoadJson(data interface{}, unsafe ...bool) (*TJson, error)

从json字符串加载TJson对象实例

func LoadToml

func LoadToml(data interface{}, unsafe ...bool) (*TJson, error)

从toml字符串格式加载为TJson对角实例

func LoadXml

func LoadXml(data interface{}, unsafe ...bool) (*TJson, error)

从xml字符串加载TJson对象实例

func LoadYaml

func LoadYaml(data interface{}, unsafe ...bool) (*TJson, error)

从yaml字符串加载TJson对象实例

func New

func New(data interface{}, unsafe ...bool) *TJson

func NewUnsafe

func NewUnsafe(data ...interface{}) *TJson

func (*TJson) Append

func (j *TJson) Append(pattern string, value interface{}) error

func (*TJson) Contains

func (j *TJson) Contains(pattern string) bool

func (*TJson) Dump

func (j *TJson) Dump()

func (*TJson) Export

func (j *TJson) Export() string

func (*TJson) Get

func (j *TJson) Get(pattern string, def ...interface{}) interface{}

func (*TJson) GetArray

func (j *TJson) GetArray(pattern string, def ...interface{}) []interface{}

func (*TJson) GetBool

func (j *TJson) GetBool(pattern string, def ...interface{}) bool

func (*TJson) GetBytes

func (j *TJson) GetBytes(pattern string, def ...interface{}) []byte

func (*TJson) GetDuration

func (j *TJson) GetDuration(pattern string, def ...interface{}) time.Duration

func (*TJson) GetFloat32

func (j *TJson) GetFloat32(pattern string, def ...interface{}) float32

func (*TJson) GetFloat64

func (j *TJson) GetFloat64(pattern string, def ...interface{}) float64

func (*TJson) GetFloats

func (j *TJson) GetFloats(pattern string, def ...interface{}) []float64

func (*TJson) GetGTime

func (j *TJson) GetGTime(pattern string, format ...string) *xtime.Time

func (*TJson) GetInt

func (j *TJson) GetInt(pattern string, def ...interface{}) int

func (*TJson) GetInt16

func (j *TJson) GetInt16(pattern string, def ...interface{}) int16

func (*TJson) GetInt32

func (j *TJson) GetInt32(pattern string, def ...interface{}) int32

func (*TJson) GetInt64

func (j *TJson) GetInt64(pattern string, def ...interface{}) int64

func (*TJson) GetInt8

func (j *TJson) GetInt8(pattern string, def ...interface{}) int8

func (*TJson) GetInterfaces

func (j *TJson) GetInterfaces(pattern string, def ...interface{}) []interface{}

func (*TJson) GetInts

func (j *TJson) GetInts(pattern string, def ...interface{}) []int

func (*TJson) GetJson

func (j *TJson) GetJson(pattern string, def ...interface{}) *TJson

func (*TJson) GetJsonMap

func (j *TJson) GetJsonMap(pattern string, def ...interface{}) map[string]*TJson

func (*TJson) GetJsons

func (j *TJson) GetJsons(pattern string, def ...interface{}) []*TJson

func (*TJson) GetMap

func (j *TJson) GetMap(pattern string, def ...interface{}) map[string]interface{}

func (*TJson) GetString

func (j *TJson) GetString(pattern string, def ...interface{}) string

func (*TJson) GetStrings

func (j *TJson) GetStrings(pattern string, def ...interface{}) []string

func (*TJson) GetStruct

func (j *TJson) GetStruct(pattern string, pointer interface{}, mapping ...map[string]string) error

func (*TJson) GetStructDeep

func (j *TJson) GetStructDeep(pattern string, pointer interface{}, mapping ...map[string]string) error

func (*TJson) GetStructs

func (j *TJson) GetStructs(pattern string, pointer interface{}, mapping ...map[string]string) error

func (*TJson) GetStructsDeep

func (j *TJson) GetStructsDeep(pattern string, pointer interface{}, mapping ...map[string]string) error

func (*TJson) GetTime

func (j *TJson) GetTime(pattern string, format ...string) time.Time

func (*TJson) GetToStruct

func (j *TJson) GetToStruct(pattern string, pointer interface{}, mapping ...map[string]string) error

func (*TJson) GetToVar

func (j *TJson) GetToVar(pattern string, pointer interface{}) error

func (*TJson) GetUint

func (j *TJson) GetUint(pattern string, def ...interface{}) uint

func (*TJson) GetUint16

func (j *TJson) GetUint16(pattern string, def ...interface{}) uint16

func (*TJson) GetUint32

func (j *TJson) GetUint32(pattern string, def ...interface{}) uint32

func (*TJson) GetUint64

func (j *TJson) GetUint64(pattern string, def ...interface{}) uint64

func (*TJson) GetUint8

func (j *TJson) GetUint8(pattern string, def ...interface{}) uint8

func (*TJson) GetVar

func (j *TJson) GetVar(pattern string, def ...interface{}) *_type.TVar

func (*TJson) IsNil

func (j *TJson) IsNil() bool

func (*TJson) Len

func (j *TJson) Len(pattern string) int

func (*TJson) MarshalJSON

func (j *TJson) MarshalJSON() ([]byte, error)

func (*TJson) Remove

func (j *TJson) Remove(pattern string) error

func (*TJson) Set

func (j *TJson) Set(pattern string, value interface{}) error

func (*TJson) SetSplitChar

func (j *TJson) SetSplitChar(char byte)

设置访问子级连接符,默认为"."

func (*TJson) SetViolenceCheck

func (j *TJson) SetViolenceCheck(enabled bool)

设置是否允许通过带"."的键名访问子级,默认false

func (*TJson) ToArray

func (j *TJson) ToArray() []interface{}

func (*TJson) ToJson

func (j *TJson) ToJson() ([]byte, error)

func (*TJson) ToJsonIndent

func (j *TJson) ToJsonIndent() ([]byte, error)

func (*TJson) ToJsonIndentString

func (j *TJson) ToJsonIndentString() (string, error)

func (*TJson) ToJsonString

func (j *TJson) ToJsonString() (string, error)

func (*TJson) ToMap

func (j *TJson) ToMap() map[string]interface{}

func (*TJson) ToStruct

func (j *TJson) ToStruct(pointer interface{}) error

func (*TJson) ToStructDeep

func (j *TJson) ToStructDeep(pointer interface{}) error

func (*TJson) ToStructs

func (j *TJson) ToStructs(pointer interface{}) error

func (*TJson) ToStructsDeep

func (j *TJson) ToStructsDeep(pointer interface{}) error

func (*TJson) ToToml

func (j *TJson) ToToml() ([]byte, error)

func (*TJson) ToTomlString

func (j *TJson) ToTomlString() (string, error)

func (*TJson) ToXml

func (j *TJson) ToXml(rootTag ...string) ([]byte, error)

func (*TJson) ToXmlIndent

func (j *TJson) ToXmlIndent(rootTag ...string) ([]byte, error)

func (*TJson) ToXmlIndentString

func (j *TJson) ToXmlIndentString(rootTag ...string) (string, error)

func (*TJson) ToXmlString

func (j *TJson) ToXmlString(rootTag ...string) (string, error)

func (*TJson) ToYaml

func (j *TJson) ToYaml() ([]byte, error)

func (*TJson) ToYamlString

func (j *TJson) ToYamlString() (string, error)

func (*TJson) Value

func (j *TJson) Value() interface{}

type TJsonDateFormatter

type TJsonDateFormatter struct {
}

func (*TJsonDateFormatter) Format

func (jf *TJsonDateFormatter) Format(val interface{}) interface{}

Jump to

Keyboard shortcuts

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