jsonobj

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2022 License: MIT Imports: 14 Imported by: 0

README

jsonobj

json object parse in golang

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONOBJ

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

func Attach

func Attach(obj interface{}) *JSONOBJ

attach 到 json 对象

func ReadArrayFromFile

func ReadArrayFromFile(fname string) (*JSONOBJ, error)

read json array from file, if file not exist, create new one, if content is empty, then return '[]'

func ReadArrayFromString

func ReadArrayFromString(szRaw string) (*JSONOBJ, error)

func ReadJsonFromFile

func ReadJsonFromFile(fname string) (*JSONOBJ, error)

read json from file, if file not exist, create new one, if content is empty, then return '{}'

func Unmarshal

func Unmarshal(body interface{}) (*JSONOBJ, error)

将字符串转为JSON对象, body 参数可以为 string []byte nil

func (*JSONOBJ) Array

func (j *JSONOBJ) Array() ([]interface{}, error)

func (*JSONOBJ) ArrayShuffle

func (j *JSONOBJ) ArrayShuffle() *JSONOBJ

func (*JSONOBJ) Bool

func (j *JSONOBJ) Bool() (bool, error)

Bool type asserts to `bool`

func (*JSONOBJ) Del

func (j *JSONOBJ) Del(key string) *JSONOBJ

func (*JSONOBJ) DelAt

func (j *JSONOBJ) DelAt(index int) error

删除数组中一项

func (*JSONOBJ) Float64

func (j *JSONOBJ) Float64() (float64, error)

Float64 coerces into a float64

func (*JSONOBJ) Float64Array

func (j *JSONOBJ) Float64Array() ([]float64, error)

func (*JSONOBJ) Get

func (j *JSONOBJ) Get(key string) *JSONOBJ

func (*JSONOBJ) GetAt

func (j *JSONOBJ) GetAt(index int) *JSONOBJ

func (*JSONOBJ) Int64

func (j *JSONOBJ) Int64() (int64, error)

Int64 coerces into an int64

func (*JSONOBJ) Int64Array

func (j *JSONOBJ) Int64Array() ([]int64, error)

func (*JSONOBJ) IsArray

func (j *JSONOBJ) IsArray() bool

func (*JSONOBJ) IsKeyExist

func (j *JSONOBJ) IsKeyExist(key string) bool

func (*JSONOBJ) IsMap

func (j *JSONOBJ) IsMap() bool

func (*JSONOBJ) IsNull

func (j *JSONOBJ) IsNull() bool

func (*JSONOBJ) Length

func (j *JSONOBJ) Length() int

func (*JSONOBJ) Map

func (j *JSONOBJ) Map() (map[string]interface{}, error)

func (*JSONOBJ) MapArray

func (j *JSONOBJ) MapArray() ([]map[string]interface{}, error)

func (*JSONOBJ) Marshal

func (j *JSONOBJ) Marshal() ([]byte, error)

func (*JSONOBJ) MustArray

func (j *JSONOBJ) MustArray() []interface{}

func (*JSONOBJ) MustBool

func (j *JSONOBJ) MustBool(args ...bool) bool

func (*JSONOBJ) MustFloat64

func (j *JSONOBJ) MustFloat64(args ...float64) float64

func (*JSONOBJ) MustFloat64Array

func (j *JSONOBJ) MustFloat64Array() []float64

func (*JSONOBJ) MustInt

func (j *JSONOBJ) MustInt(args ...int) int

func (*JSONOBJ) MustInt64

func (j *JSONOBJ) MustInt64(args ...int64) int64

func (*JSONOBJ) MustInt64Array

func (j *JSONOBJ) MustInt64Array() []int64

func (*JSONOBJ) MustMap

func (j *JSONOBJ) MustMap() map[string]interface{}

func (*JSONOBJ) MustMapArray

func (j *JSONOBJ) MustMapArray() []map[string]interface{}

func (*JSONOBJ) MustString

func (j *JSONOBJ) MustString(args ...string) string

func (*JSONOBJ) MustStringArray

func (j *JSONOBJ) MustStringArray() []string

func (*JSONOBJ) MustStringTrimSpace added in v1.0.1

func (j *JSONOBJ) MustStringTrimSpace(args ...string) string

func (*JSONOBJ) MustUint32

func (j *JSONOBJ) MustUint32(args ...uint32) uint32

func (*JSONOBJ) MustUint64

func (j *JSONOBJ) MustUint64(args ...uint64) uint64

func (*JSONOBJ) NilToArray

func (j *JSONOBJ) NilToArray() *JSONOBJ

func (*JSONOBJ) NilToMap

func (j *JSONOBJ) NilToMap() *JSONOBJ

func (*JSONOBJ) PopBack

func (j *JSONOBJ) PopBack() error

数组尾部删除

func (*JSONOBJ) PopFront

func (j *JSONOBJ) PopFront() error

数组头部删除

func (*JSONOBJ) PushBack

func (j *JSONOBJ) PushBack(item interface{}) error

数组尾部追加

func (*JSONOBJ) PushFront

func (j *JSONOBJ) PushFront(item interface{}) error

数组头部添加

func (*JSONOBJ) RawData

func (j *JSONOBJ) RawData() interface{}

func (*JSONOBJ) SaveToFile

func (j *JSONOBJ) SaveToFile(fname string, wellFormat bool) error

if the file not exist, create a new one, otherwise truncates it before writing

func (*JSONOBJ) Set

func (j *JSONOBJ) Set(key string, v interface{}) error

func (*JSONOBJ) String

func (j *JSONOBJ) String() (string, error)

func (*JSONOBJ) StringArray

func (j *JSONOBJ) StringArray() ([]string, error)

StringArray type asserts to an `array` of `string`

func (*JSONOBJ) Stringify

func (j *JSONOBJ) Stringify() string

func (*JSONOBJ) ToString

func (j *JSONOBJ) ToString() string

强迫对象转为字符串

func (*JSONOBJ) Uint32

func (j *JSONOBJ) Uint32() (uint32, error)

uint32 coerces into an uint32

func (*JSONOBJ) Uint64

func (j *JSONOBJ) Uint64() (uint64, error)

Uint64 coerces into an uint64

func (*JSONOBJ) VerifyArrayValue

func (j *JSONOBJ) VerifyArrayValue(key ...string) error

如果key存在,检查它是不是[]interface{}类型.如果key不存在则检查当前对象

func (*JSONOBJ) VerifyEmail

func (j *JSONOBJ) VerifyEmail(key string) error

如果key存在,则检查它是不是string类型, 是否符合email名称要求

func (*JSONOBJ) VerifyInt64ArrayValue

func (j *JSONOBJ) VerifyInt64ArrayValue(key ...string) error

如果key存在,检查它是不是[]int64类型.如果key不存在则检查当前对象

func (*JSONOBJ) VerifyInt64Range

func (j *JSONOBJ) VerifyInt64Range(key string, min int64, max int64) error

如果key存在,检查它是不是int64类型, 且在范围[min, max]内

func (*JSONOBJ) VerifyInt64Value

func (j *JSONOBJ) VerifyInt64Value(key ...string) error

如果key存在,检查它是不是int64类型

func (*JSONOBJ) VerifyMapArrayValue

func (j *JSONOBJ) VerifyMapArrayValue(key ...string) error

如果key存在,检查它是不是[]map[string]interface{}类型.如果key不存在则检查当前对象

func (*JSONOBJ) VerifyMapKeyExist

func (j *JSONOBJ) VerifyMapKeyExist(key ...string) error

验证key必须存在

func (*JSONOBJ) VerifyMapKeyInArray

func (j *JSONOBJ) VerifyMapKeyInArray(keys []string) error

验证key必须在范围内

func (*JSONOBJ) VerifyStringArrayValue

func (j *JSONOBJ) VerifyStringArrayValue(key ...string) error

如果key存在,检查它是不是[]string类型.如果key不存在则检查当前对象

func (*JSONOBJ) VerifyStringLength

func (j *JSONOBJ) VerifyStringLength(key string, minLen int, maxLen int) error

如果key存在,则检查它是不是string类型, 且长度在范围[minLen, maxLen]内

func (*JSONOBJ) VerifyStringValue

func (j *JSONOBJ) VerifyStringValue(key ...string) error

如果key存在,检查它是不是string类型

Jump to

Keyboard shortcuts

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