jsonutils

package module
v0.0.0-...-6dd39f8 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2018 License: Apache-2.0 Imports: 15 Imported by: 0

README

jsonutils

Golang package to interact with JSON.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	JSONNull  = &JSONValue{}
	JSONTrue  = &JSONBool{data: true}
	JSONFalse = &JSONBool{data: false}
)
View Source
var (
	JSONDictType      reflect.Type
	JSONArrayType     reflect.Type
	JSONStringType    reflect.Type
	JSONIntType       reflect.Type
	JSONFloatType     reflect.Type
	JSONBoolType      reflect.Type
	JSONDictPtrType   reflect.Type
	JSONArrayPtrType  reflect.Type
	JSONStringPtrType reflect.Type
	JSONIntPtrType    reflect.Type
	JSONFloatPtrType  reflect.Type
	JSONBoolPtrType   reflect.Type
	JSONObjectType    reflect.Type
)

Functions

func CheckRequiredFields

func CheckRequiredFields(data JSONObject, fields []string) error

func GetAnyString

func GetAnyString(json JSONObject, keys []string) string

func GetQueryStringArray

func GetQueryStringArray(query JSONObject, key string) []string

func JSONArray2StringArray

func JSONArray2StringArray(arr []JSONObject) []string

func JSONDeserialize

func JSONDeserialize(objType reflect.Type, strVal string) (gotypes.ISerializable, error)

func QueryBoolean

func QueryBoolean(query JSONObject, key string, defVal bool) bool

func Update

func Update(dst, src interface{}) error

Types

type JSONArray

type JSONArray struct {
	JSONValue
	// contains filtered or unexported fields
}

func NewArray

func NewArray(objs ...JSONObject) *JSONArray

func NewStringArray

func NewStringArray(arr []string) *JSONArray

func (*JSONArray) Add

func (this *JSONArray) Add(objs ...JSONObject)

func (*JSONArray) Copy

func (this *JSONArray) Copy() *JSONArray

func (*JSONArray) Equals

func (arr *JSONArray) Equals(json JSONObject) bool

func (*JSONArray) GetArray

func (this *JSONArray) GetArray(keys ...string) ([]JSONObject, error)

func (*JSONArray) GetAt

func (this *JSONArray) GetAt(i int, keys ...string) (JSONObject, error)

func (*JSONArray) GetString

func (this *JSONArray) GetString(keys ...string) (string, error)

func (*JSONArray) GetStringArray

func (this *JSONArray) GetStringArray() []string

func (*JSONArray) IsZero

func (this *JSONArray) IsZero() bool

func (*JSONArray) PrettyString

func (this *JSONArray) PrettyString() string

func (*JSONArray) Size

func (this *JSONArray) Size() int

func (*JSONArray) String

func (this *JSONArray) String() string

func (*JSONArray) Unmarshal

func (this *JSONArray) Unmarshal(obj interface{}, keys ...string) error

func (*JSONArray) Value

func (this *JSONArray) Value() []JSONObject

func (*JSONArray) YAMLString

func (this *JSONArray) YAMLString() string

type JSONBool

type JSONBool struct {
	JSONValue
	// contains filtered or unexported fields
}

func (*JSONBool) Bool

func (this *JSONBool) Bool(keys ...string) (bool, error)

func (*JSONBool) Equals

func (o *JSONBool) Equals(json JSONObject) bool

func (*JSONBool) GetArray

func (this *JSONBool) GetArray(keys ...string) ([]JSONObject, error)

func (*JSONBool) GetString

func (this *JSONBool) GetString(keys ...string) (string, error)

func (*JSONBool) IsZero

func (this *JSONBool) IsZero() bool

func (*JSONBool) PrettyString

func (this *JSONBool) PrettyString() string

func (*JSONBool) String

func (this *JSONBool) String() string

func (*JSONBool) Value

func (this *JSONBool) Value() bool

func (*JSONBool) YAMLString

func (this *JSONBool) YAMLString() string

type JSONDict

type JSONDict struct {
	JSONValue
	// contains filtered or unexported fields
}

func NewDict

func NewDict(objs ...JSONPair) *JSONDict

func (*JSONDict) Add

func (this *JSONDict) Add(o JSONObject, keys ...string) error

func (*JSONDict) Bool

func (this *JSONDict) Bool(keys ...string) (bool, error)

func (*JSONDict) Contains

func (this *JSONDict) Contains(keys ...string) bool

func (*JSONDict) ContainsIgnoreCases

func (this *JSONDict) ContainsIgnoreCases(keys ...string) bool

func (*JSONDict) Copy

func (this *JSONDict) Copy(excludes ...string) *JSONDict

func (*JSONDict) CopyExcludes

func (this *JSONDict) CopyExcludes(excludes ...string) *JSONDict

func (*JSONDict) CopyIncludes

func (this *JSONDict) CopyIncludes(includes ...string) *JSONDict

func (*JSONDict) Equals

func (dict *JSONDict) Equals(json JSONObject) bool

func (*JSONDict) Float

func (this *JSONDict) Float(keys ...string) (float64, error)

func (*JSONDict) Get

func (this *JSONDict) Get(keys ...string) (JSONObject, error)

func (*JSONDict) GetArray

func (this *JSONDict) GetArray(keys ...string) ([]JSONObject, error)

func (*JSONDict) GetAt

func (this *JSONDict) GetAt(i int, keys ...string) (JSONObject, error)

func (*JSONDict) GetIgnoreCases

func (this *JSONDict) GetIgnoreCases(keys ...string) (JSONObject, error)

func (*JSONDict) GetMap

func (this *JSONDict) GetMap(keys ...string) (map[string]JSONObject, error)

func (*JSONDict) GetString

func (this *JSONDict) GetString(keys ...string) (string, error)

func (*JSONDict) GetTime

func (this *JSONDict) GetTime(keys ...string) (time.Time, error)

func (*JSONDict) Int

func (this *JSONDict) Int(keys ...string) (int64, error)

func (*JSONDict) IsZero

func (this *JSONDict) IsZero() bool

func (*JSONDict) PrettyString

func (this *JSONDict) PrettyString() string

func (*JSONDict) QueryString

func (this *JSONDict) QueryString() string

func (*JSONDict) Remove

func (this *JSONDict) Remove(key string, caseSensitive bool) bool

func (*JSONDict) Set

func (this *JSONDict) Set(key string, value JSONObject)

func (*JSONDict) Size

func (this *JSONDict) Size() int

func (*JSONDict) SortedKeys

func (this *JSONDict) SortedKeys() []string

func (*JSONDict) String

func (this *JSONDict) String() string

func (*JSONDict) Unmarshal

func (this *JSONDict) Unmarshal(obj interface{}, keys ...string) error

func (*JSONDict) Update

func (dict *JSONDict) Update(json JSONObject)

func (*JSONDict) UpdateDefault

func (dict *JSONDict) UpdateDefault(json JSONObject)

func (*JSONDict) Value

func (this *JSONDict) Value() map[string]JSONObject

func (*JSONDict) YAMLString

func (this *JSONDict) YAMLString() string

type JSONError

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

func NewJSONError

func NewJSONError(str []byte, pos int, msg string) *JSONError

func (*JSONError) Error

func (e *JSONError) Error() string

type JSONFloat

type JSONFloat struct {
	JSONValue
	// contains filtered or unexported fields
}

func NewFloat

func NewFloat(val float64) *JSONFloat

func (*JSONFloat) Equals

func (o *JSONFloat) Equals(json JSONObject) bool

func (*JSONFloat) Float

func (this *JSONFloat) Float(keys ...string) (float64, error)

func (*JSONFloat) GetArray

func (this *JSONFloat) GetArray(keys ...string) ([]JSONObject, error)

func (*JSONFloat) GetString

func (this *JSONFloat) GetString(keys ...string) (string, error)

func (*JSONFloat) IsZero

func (this *JSONFloat) IsZero() bool

func (*JSONFloat) PrettyString

func (this *JSONFloat) PrettyString() string

func (*JSONFloat) String

func (this *JSONFloat) String() string

func (*JSONFloat) Value

func (this *JSONFloat) Value() float64

func (*JSONFloat) YAMLString

func (this *JSONFloat) YAMLString() string

type JSONInt

type JSONInt struct {
	JSONValue
	// contains filtered or unexported fields
}

func NewInt

func NewInt(val int64) *JSONInt

func (*JSONInt) Equals

func (o *JSONInt) Equals(json JSONObject) bool

func (*JSONInt) GetArray

func (this *JSONInt) GetArray(keys ...string) ([]JSONObject, error)

func (*JSONInt) GetString

func (this *JSONInt) GetString(keys ...string) (string, error)

func (*JSONInt) Int

func (this *JSONInt) Int(keys ...string) (int64, error)

func (*JSONInt) IsZero

func (this *JSONInt) IsZero() bool

func (*JSONInt) PrettyString

func (this *JSONInt) PrettyString() string

func (*JSONInt) String

func (this *JSONInt) String() string

func (*JSONInt) Value

func (this *JSONInt) Value() int64

func (*JSONInt) YAMLString

func (this *JSONInt) YAMLString() string

type JSONObject

type JSONObject interface {
	gotypes.ISerializable

	// String() string
	PrettyString() string

	YAMLString() string
	QueryString() string

	Contains(keys ...string) bool
	ContainsIgnoreCases(keys ...string) bool
	Get(keys ...string) (JSONObject, error)
	GetIgnoreCases(keys ...string) (JSONObject, error)
	GetAt(i int, keys ...string) (JSONObject, error)
	Int(keys ...string) (int64, error)
	Float(keys ...string) (float64, error)
	Bool(keys ...string) (bool, error)
	GetMap(keys ...string) (map[string]JSONObject, error)
	GetArray(keys ...string) ([]JSONObject, error)
	GetTime(keys ...string) (time.Time, error)
	GetString(keys ...string) (string, error)
	Unmarshal(obj interface{}, keys ...string) error
	Equals(obj JSONObject) bool
	// contains filtered or unexported methods
}

func Marshal

func Marshal(obj interface{}) JSONObject

func Parse

func Parse(str []byte) (JSONObject, error)

func ParseQueryString

func ParseQueryString(str string) (JSONObject, error)

func ParseString

func ParseString(str string) (JSONObject, error)

func ParseYAML

func ParseYAML(str string) (JSONObject, error)

type JSONPair

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

type JSONString

type JSONString struct {
	JSONValue
	// contains filtered or unexported fields
}

func NewString

func NewString(val string) *JSONString

func NewTimeString

func NewTimeString(tm time.Time) *JSONString

func (*JSONString) Bool

func (this *JSONString) Bool(keys ...string) (bool, error)

func (*JSONString) Equals

func (o *JSONString) Equals(json JSONObject) bool

func (*JSONString) Float

func (this *JSONString) Float(keys ...string) (float64, error)

func (*JSONString) GetArray

func (this *JSONString) GetArray(keys ...string) ([]JSONObject, error)

func (*JSONString) GetString

func (this *JSONString) GetString(keys ...string) (string, error)

func (*JSONString) GetTime

func (this *JSONString) GetTime(keys ...string) (time.Time, error)

func (*JSONString) Int

func (this *JSONString) Int(keys ...string) (int64, error)

func (*JSONString) IsZero

func (this *JSONString) IsZero() bool

func (*JSONString) PrettyString

func (this *JSONString) PrettyString() string

func (*JSONString) String

func (this *JSONString) String() string

func (*JSONString) Value

func (this *JSONString) Value() string

func (*JSONString) YAMLString

func (this *JSONString) YAMLString() string

type JSONValue

type JSONValue struct {
}

func (*JSONValue) Bool

func (this *JSONValue) Bool(keys ...string) (bool, error)

func (*JSONValue) Contains

func (this *JSONValue) Contains(keys ...string) bool

func (*JSONValue) ContainsIgnoreCases

func (this *JSONValue) ContainsIgnoreCases(keys ...string) bool

func (*JSONValue) Equals

func (o *JSONValue) Equals(json JSONObject) bool

func (*JSONValue) Float

func (this *JSONValue) Float(keys ...string) (float64, error)

func (*JSONValue) Get

func (this *JSONValue) Get(keys ...string) (JSONObject, error)

func (*JSONValue) GetArray

func (this *JSONValue) GetArray(keys ...string) ([]JSONObject, error)

func (*JSONValue) GetAt

func (this *JSONValue) GetAt(i int, keys ...string) (JSONObject, error)

func (*JSONValue) GetIgnoreCases

func (this *JSONValue) GetIgnoreCases(keys ...string) (JSONObject, error)

func (*JSONValue) GetMap

func (this *JSONValue) GetMap(keys ...string) (map[string]JSONObject, error)

func (*JSONValue) GetString

func (this *JSONValue) GetString(keys ...string) (string, error)

func (*JSONValue) GetTime

func (this *JSONValue) GetTime(keys ...string) (time.Time, error)

func (*JSONValue) Int

func (this *JSONValue) Int(keys ...string) (int64, error)

func (*JSONValue) IsZero

func (this *JSONValue) IsZero() bool

func (*JSONValue) PrettyString

func (this *JSONValue) PrettyString() string

func (*JSONValue) QueryString

func (this *JSONValue) QueryString() string

func (*JSONValue) String

func (this *JSONValue) String() string

func (*JSONValue) Unmarshal

func (this *JSONValue) Unmarshal(obj interface{}, keys ...string) error

func (*JSONValue) YAMLString

func (this *JSONValue) YAMLString() string

Jump to

Keyboard shortcuts

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