freejson

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

用于处理松散的JSON数据。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsBool

func AsBool(v interface{}, def bool) bool

func AsStr

func AsStr(v interface{}, def string) string

func AsStringArray

func AsStringArray(v interface{}, def []string) []string

func AsTime

func AsTime(v interface{}, def time.Time) time.Time

func BoolAsInt

func BoolAsInt(b bool) int

func Clone

func Clone(v interface{}) (interface{}, error)

func FromFreejson

func FromFreejson(freejsonData interface{}, v interface{}) error

func Marshal

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

func MarshalIndent

func MarshalIndent(v interface{}, prefix, indent string) ([]byte, error)

func MarshalIndentString

func MarshalIndentString(v interface{}, def string) string

func MarshalString

func MarshalString(v interface{}, def string) string

func MustClone

func MustClone(v interface{}) interface{}

func ToBool

func ToBool(v interface{}, def bool) bool

func ToFloat64

func ToFloat64(v interface{}, def float64) float64

func ToFreejson

func ToFreejson(v interface{}) (interface{}, error)

func ToInt

func ToInt(v interface{}, def int) int

func ToInt64

func ToInt64(v interface{}, def int64) int64

func ToStr

func ToStr(v interface{}, def string) string

func ToTime

func ToTime(v interface{}, def time.Time) time.Time

func Unmarshal

func Unmarshal(data []byte, valDec ValueDecoder) (interface{}, error)

Types

type Array

type Array []interface{}

func AsArray

func AsArray(v interface{}, def Array) Array

func ToArray

func ToArray(v interface{}, def Array) Array

func (Array) Add

func (a Array) Add(vs ...interface{}) Array

func (Array) ArrayAt

func (a Array) ArrayAt(index int, def Array) Array

func (Array) AsArrayAt

func (a Array) AsArrayAt(index int, def Array) Array

func (Array) AsStrAt

func (a Array) AsStrAt(index int, def string) string

func (Array) AsStringArrayAt

func (a Array) AsStringArrayAt(index int, def []string) []string

func (Array) AsTimeAt

func (a Array) AsTimeAt(index int, def time.Time) time.Time

func (Array) BoolAt

func (a Array) BoolAt(index int, def bool) bool

func (Array) Clear

func (a Array) Clear() Array

func (Array) Each

func (a Array) Each(f func(index int, v interface{}))

func (Array) EachElem

func (a Array) EachElem(f func(v interface{}))

func (Array) EachIndex

func (a Array) EachIndex(f func(index int))

func (Array) FieldType

func (a Array) FieldType(index int) ValueType

func (Array) Filter

func (a Array) Filter(result Array, pred func(v interface{}) bool) Array

func (Array) Float64At

func (a Array) Float64At(index int, def float64) float64

func (Array) Has

func (a Array) Has(index int) bool

func (Array) Int64At

func (a Array) Int64At(index int, def int64) int64

func (Array) IntAt

func (a Array) IntAt(index, def int) int

func (Array) IntfAt

func (a Array) IntfAt(index int, def interface{}) interface{}

func (Array) Len

func (a Array) Len() int

func (Array) ObjectAt

func (a Array) ObjectAt(index int, def Object) Object

func (Array) RemoveIf

func (a Array) RemoveIf(pred func(index int, v interface{}) bool) Array

func (Array) Set

func (a Array) Set(index int, v interface{})

func (Array) StrAt

func (a Array) StrAt(index int, def string) string

func (Array) String

func (a Array) String() string

func (Array) TimeAt

func (a Array) TimeAt(index int, def time.Time) time.Time

type Cloneable

type Cloneable interface {
	FJClone() (interface{}, error)
}

type Object

type Object map[string]interface{}

func ToObject

func ToObject(v interface{}, def Object) Object

func (Object) ArrayField

func (o Object) ArrayField(f string, def Array) Array

func (Object) AsArrayField

func (o Object) AsArrayField(f string, def Array) Array

func (Object) AsBoolField

func (o Object) AsBoolField(f string, def bool) bool

func (Object) AsStrField

func (o Object) AsStrField(f, def string) string

func (Object) AsStringArrayField

func (o Object) AsStringArrayField(f string, def []string) []string

func (Object) AsTimeField

func (o Object) AsTimeField(f string, def time.Time) time.Time

func (Object) BoolField

func (o Object) BoolField(f string, def bool) bool

func (Object) BoolFieldAsInt

func (o Object) BoolFieldAsInt(f string, def bool) int

func (Object) Clear

func (o Object) Clear()

func (Object) Each

func (o Object) Each(f func(k string, v interface{}))

func (Object) EachKey

func (o Object) EachKey(f func(k string))

func (Object) EachValue

func (o Object) EachValue(f func(v interface{}))

func (Object) Ensure

func (o Object) Ensure(f string, v interface{})

func (Object) EnsureF

func (o Object) EnsureF(f string, vf func(f string) (interface{}, error)) error

func (Object) FieldType

func (o Object) FieldType(f string) ValueType

func (Object) Filter

func (o Object) Filter(result Object, pred func(k string, v interface{}) bool) Object

func (Object) Float64Field

func (o Object) Float64Field(f string, def float64) float64

func (Object) Has

func (o Object) Has(f string) bool

func (Object) Int64Field

func (o Object) Int64Field(f string, def int64) int64

func (Object) IntField

func (o Object) IntField(f string, def int) int

func (Object) IntfField

func (o Object) IntfField(f string, def interface{}) interface{}

func (Object) Keys

func (o Object) Keys() []string

func (Object) Len

func (o Object) Len() int

func (Object) ObjectField

func (o Object) ObjectField(f string, def Object) Object

func (Object) Remove

func (o Object) Remove(f string)

func (Object) RemoveIf

func (o Object) RemoveIf(pred func(f string, v interface{}) bool)

func (Object) Set

func (o Object) Set(f string, v interface{})

func (Object) SetIfExists

func (o Object) SetIfExists(f string, v interface{})

func (Object) SetNotNil

func (o Object) SetNotNil(f string, v interface{})

func (Object) SetNotNilF

func (o Object) SetNotNilF(f string, vf func(f string) (interface{}, error)) error

func (Object) StrField

func (o Object) StrField(f, def string) string

func (Object) String

func (o Object) String() string

func (Object) TimeField

func (o Object) TimeField(f string, def time.Time) time.Time

type ValueDecoder

type ValueDecoder func(interface{}) (interface{}, error)

type ValueType

type ValueType int
const (
	UnknownField ValueType = 0
	NoField      ValueType = 1
	NullField    ValueType = 2
	NumField     ValueType = 3
	BoolField    ValueType = 4
	StrField     ValueType = 5
	ArrayField   ValueType = 6
	ObjectField  ValueType = 7
)

func TypeOf

func TypeOf(v interface{}) ValueType

Jump to

Keyboard shortcuts

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