Documentation ¶
Overview ¶
Written by Daniel Krom 2018
Written by Daniel Krom 2018
// added ability to ignore lock
Written by Daniel Krom 2018
Written by Daniel Krom 2018
Written by Daniel Krom 2018
Written by Daniel Krom 2018
Index ¶
- func EqualsDeep(left *JSON, right *JSON) bool
- type JSON
- func (jsn *JSON) At(key interface{}, keys ...interface{}) *JSON
- func (jsn *JSON) Clone() *JSON
- func (jsn *JSON) DeleteMapKey(key string) *JSON
- func (jsn *JSON) GetBool() (isBool bool, value bool)
- func (jsn *JSON) GetFloat32() (isFloat32 bool, value float32)
- func (jsn *JSON) GetFloat64() (isFloat64 bool, value float64)
- func (jsn *JSON) GetInt() (isInt bool, value int)
- func (jsn *JSON) GetInt16() (isInt16 bool, value int16)
- func (jsn *JSON) GetInt32() (isInt32 bool, value int32)
- func (jsn *JSON) GetInt64() (isInt64 bool, value int64)
- func (jsn *JSON) GetInt8() (isInt8 bool, value int8)
- func (jsn *JSON) GetMap() (isMap bool, value map[string]*JSON)
- func (jsn *JSON) GetObjectKeys() []string
- func (jsn *JSON) GetSlice() (isSlice bool, value []*JSON)
- func (jsn *JSON) GetSliceLen() int
- func (jsn *JSON) GetString() (isString bool, value string)
- func (jsn *JSON) GetUint() (isUint bool, value uint)
- func (jsn *JSON) GetUint16() (isUint16 bool, value uint16)
- func (jsn *JSON) GetUint32() (isUint32 bool, value uint32)
- func (jsn *JSON) GetUint64() (isUint64 bool, value uint64)
- func (jsn *JSON) GetUint8() (isUint8 bool, value uint8)
- func (jsn *JSON) GetUnsafeBool() (value bool)
- func (jsn *JSON) GetUnsafeFloat32() (value float32)
- func (jsn *JSON) GetUnsafeFloat64() (value float64)
- func (jsn *JSON) GetUnsafeInt() (value int)
- func (jsn *JSON) GetUnsafeInt16() (value int16)
- func (jsn *JSON) GetUnsafeInt32() (value int32)
- func (jsn *JSON) GetUnsafeInt64() (value int64)
- func (jsn *JSON) GetUnsafeInt8() (value int8)
- func (jsn *JSON) GetUnsafeMap() (value map[string]*JSON)
- func (jsn *JSON) GetUnsafeSlice() (value []*JSON)
- func (jsn *JSON) GetUnsafeString() (value string)
- func (jsn *JSON) GetUnsafeUint() (value uint)
- func (jsn *JSON) GetUnsafeUint16() (value uint16)
- func (jsn *JSON) GetUnsafeUint32() (value uint32)
- func (jsn *JSON) GetUnsafeUint64() (value uint64)
- func (jsn *JSON) GetUnsafeUint8() (value uint8)
- func (jsn *JSON) IsBool() bool
- func (jsn *JSON) IsFloat32() bool
- func (jsn *JSON) IsFloat64() bool
- func (jsn *JSON) IsInt() bool
- func (jsn *JSON) IsInt16() bool
- func (jsn *JSON) IsInt32() bool
- func (jsn *JSON) IsInt64() bool
- func (jsn *JSON) IsInt8() bool
- func (jsn *JSON) IsMap() bool
- func (jsn *JSON) IsNil() bool
- func (jsn *JSON) IsNumber() bool
- func (jsn *JSON) IsPrimitive() bool
- func (jsn *JSON) IsSlice() bool
- func (jsn *JSON) IsString() bool
- func (jsn *JSON) IsType(p reflect.Kind) bool
- func (jsn *JSON) IsUint() bool
- func (jsn *JSON) IsUint16() bool
- func (jsn *JSON) IsUint32() bool
- func (jsn *JSON) IsUint64() bool
- func (jsn *JSON) IsUint8() bool
- func (jsn *JSON) MapSet(key string, value interface{}) *JSON
- func (jsn *JSON) MutateToFloat() (success bool)
- func (jsn *JSON) MutateToInt() (success bool)
- func (jsn *JSON) MutateToString() (success bool)
- func (jsn *JSON) MutateToUnsignedInt() (success bool)
- func (jsn *JSON) ObjectFilter(cb func(jsn *JSON, key string) (shouldKeep bool)) *JSON
- func (jsn *JSON) ObjectForEach(cb func(jsn *JSON, key string)) *JSON
- func (jsn *JSON) ObjectKeyExists(key string) (exists bool)
- func (jsn *JSON) ObjectMap(cb func(jsn *JSON, key string) *JSON) *JSON
- func (jsn *JSON) Set(v interface{}) *JSON
- func (jsn *JSON) SliceAppend(value ...interface{}) *JSON
- func (jsn *JSON) SliceAppendBegin(value ...interface{}) *JSON
- func (jsn *JSON) SliceFilter(cb func(jsn *JSON, index int) (shouldKeep bool)) *JSON
- func (jsn *JSON) SliceForEach(cb func(jsn *JSON, index int)) *JSON
- func (jsn *JSON) SliceMap(cb func(jsn *JSON, index int) *JSON) *JSON
- func (jsn *JSON) SliceSet(index int, value interface{}) *JSON
- func (jsn *JSON) ToInterface() interface{}
- func (jsn *JSON) ToJSON() ([]byte, error)
- func (jsn *JSON) ToJSONString() (string, error)
- func (jsn *JSON) ToUnsafeJSON() (data []byte)
- func (jsn *JSON) ToUnsafeJSONString() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EqualsDeep ¶
Types ¶
type JSON ¶
type JSON struct {
// contains filtered or unexported fields
}
func New ¶
func New(value interface{}) *JSON
New Jonson Object with the value of the interface. the reference to interface is lost and it is deeply cloned
Possible types: Primitive Map[string]interface{} Slice struct
func NewEmptyJSON ¶
func NewEmptyJSON() *JSON
NewEmptyJSON Creates a new empty Jonson object with null value
func NewEmptyJSONArray ¶
func NewEmptyJSONArray() *JSON
NewEmptyJSONArray Creates a new empty Jonson object with empty array []
func NewEmptyJSONMap ¶
func NewEmptyJSONMap() *JSON
NewEmptyJSONMap Creates a new empty Jonson object with empty map {}
func ParseUnsafe ¶
ParseUnsafe JSON returns null json if error
func (*JSON) At ¶
At returns the jonson value at some path can be chained or\and using multiple keys String key will assume the jonson is object int key will assume the jonson is slice if the path is wrong the empty json is returned
Jonson.ParseUnsafe([]byte("{\"foo\" : \"bar\"}")).At("keyThatDoesNotExists").At("subKey", 3, 6 ,90)
At("key","subKey",5, 7) equals to .At("key").At(5).At(7) equals to At("key",5).At(7)
func (*JSON) DeleteMapKey ¶
func (*JSON) GetFloat32 ¶
func (*JSON) GetFloat64 ¶
func (*JSON) GetObjectKeys ¶
func (*JSON) GetSliceLen ¶
func (*JSON) GetUnsafeBool ¶
func (*JSON) GetUnsafeFloat32 ¶
func (*JSON) GetUnsafeFloat64 ¶
func (*JSON) GetUnsafeInt ¶
func (*JSON) GetUnsafeInt16 ¶
func (*JSON) GetUnsafeInt32 ¶
func (*JSON) GetUnsafeInt64 ¶
func (*JSON) GetUnsafeInt8 ¶
func (*JSON) GetUnsafeMap ¶
func (*JSON) GetUnsafeSlice ¶
func (*JSON) GetUnsafeString ¶
func (*JSON) GetUnsafeUint ¶
func (*JSON) GetUnsafeUint16 ¶
func (*JSON) GetUnsafeUint32 ¶
func (*JSON) GetUnsafeUint64 ¶
func (*JSON) GetUnsafeUint8 ¶
func (*JSON) IsNumber ¶
IsNumber returns a boolean indicates is the value is number, can be any valid number type
func (*JSON) IsPrimitive ¶
func (*JSON) MapSet ¶
Set a value to MapObject if key doesn't exists, it creates it
if current json is not map, it does nothing
func (*JSON) MutateToFloat ¶
func (*JSON) MutateToInt ¶
func (*JSON) MutateToString ¶
func (*JSON) MutateToUnsignedInt ¶
func (*JSON) ObjectFilter ¶
iterates on object, removing each value that cb returns false
func (*JSON) ObjectForEach ¶
iterates on object
func (*JSON) ObjectKeyExists ¶
func (*JSON) Set ¶
Sets a value to the current JSON, Makes a deep copy of the interface, removing the original reference
func (*JSON) SliceAppend ¶
Append a value at the end of the slice
if current json slice, it does nothing
multiple values will append in the order of the values SliceAppend(1,2,3,4) -> [oldSlice..., 1,2,3,4]
func (*JSON) SliceAppendBegin ¶
Append a value at the start of the slice
if current json slice, it does nothing multiple values will append begin in the order of the values SliceAppend(1,2,3,4) -> [4,3,2,1, oldSlice...]
func (*JSON) SliceFilter ¶
iterates on slice with filter callback, removes values that callback returned false
func (*JSON) SliceForEach ¶
iterates on slice
func (*JSON) SliceSet ¶
Sets a value at index to current slice
if value isn't slice, it does nothing User must make sure the length of the slice contains the index
func (*JSON) ToInterface ¶
func (jsn *JSON) ToInterface() interface{}
ToInterface returns the entire jonson tree as interface of the value e.g [Jonson(5), Jonson("str"), Jonson(map[string]Jonson)] -> to [5, "str", map[string]interface{}]
func (*JSON) ToJSONString ¶
ToJSONString converts Jonson to json string
func (*JSON) ToUnsafeJSON ¶
ToUnsafeJSON converts Jonson to byte array (serialize) returns empty byte array if error
func (*JSON) ToUnsafeJSONString ¶
ToUnsafeJSONString converts Jonson to json string returns empty string if error