Documentation
¶
Index ¶
- Variables
- func UpperCamelCase(str string) string
- type JSONNode
- func (that *JSONNode) Array(size int) *[]JSONNode
- func (that *JSONNode) At(val ...interface{}) *JSONNode
- func (that *JSONNode) Copy(other *JSONNode, deepCopy bool) *JSONNode
- func (that *JSONNode) DebugPrint(prefix string)
- func (that *JSONNode) DebugProspect(indentlevel int, indentchar string)
- func (that *JSONNode) DelKey(key string) *JSONNode
- func (that *JSONNode) Get() interface{}
- func (that *JSONNode) GetKeys() []interface{}
- func (that *JSONNode) GetType() JSONNodeType
- func (that *JSONNode) Len() int
- func (that *JSONNode) Map(key string) *JSONNode
- func (that *JSONNode) MarshalJSON() ([]byte, error)
- func (that *JSONNode) MustGetBool() bool
- func (that *JSONNode) MustGetFloat32() float32
- func (that *JSONNode) MustGetFloat64() float64
- func (that *JSONNode) MustGetInt() int
- func (that *JSONNode) MustGetInt8() int8
- func (that *JSONNode) MustGetInt16() int16
- func (that *JSONNode) MustGetInt32() int32
- func (that *JSONNode) MustGetInt64() int64
- func (that *JSONNode) MustGetString() string
- func (that *JSONNode) MustGetUint() uint
- func (that *JSONNode) MustGetUint8() uint8
- func (that *JSONNode) MustGetUint16() uint16
- func (that *JSONNode) MustGetUint32() uint32
- func (that *JSONNode) MustGetUint64() uint64
- func (that *JSONNode) Print()
- func (that *JSONNode) SetType(t JSONNodeType) *JSONNode
- func (that *JSONNode) UnmarshalDontExpand(val bool, recurse bool) *JSONNode
- func (that *JSONNode) UnmarshalJSON(data []byte) error
- func (that *JSONNode) Unset()
- func (that *JSONNode) Val(val interface{})
- type JSONNodeType
Constants ¶
This section is empty.
Variables ¶
var ErrorArrayNegativeValue = errors.New("jsongo negative index for array")
ErrorArrayNegativeValue error if you ask for a negative index in an array
var ErrorAtUnsupportedType = errors.New("jsongo Unsupported Type as At argument")
ErrorArrayNegativeValue error if you ask for a negative index in an array
var ErrorCopyType = errors.New("jsongo: Copy: This JSONNode is not a TypeUndefined")
ErrorCopyType error if you try to call Copy on a JSONNode that isnt a TypeUndefined
var ErrorDeleteKey = errors.New("jsongo: DelKey: This JSONNode is not a TypeMap")
ErrorDeleteKey error if you try to call DelKey on a JSONNode that isnt a TypeMap
var ErrorGetKeys = errors.New("jsongo: GetKeys: JSONNode is not a TypeMap or TypeArray")
ErrorGetKeys error if you try to get the keys from a JSONNode that isnt a TypeMap or a TypeArray
var ErrorKeyAlreadyExist = errors.New("jsongo key already exist")
ErrorKeyAlreadyExist error if a key already exist in current JSONNode
var ErrorMultipleType = errors.New("jsongo this node is already set to a different jsonNodeType")
ErrorMultipleType error if a JSONNode already got a different type of value
var ErrorRetrieveUserValue = errors.New("jsongo Cannot retrieve node's value which is not of type value")
ErrorRetrieveUserValue error if you ask the value of a node that is not a value node
var ErrorTypeUnmarshaling = errors.New("jsongo Wrong type when Unmarshaling")
ErrorTypeUnmarshaling error if you try to unmarshal something in the wrong type
var ErrorUnknowType = errors.New("jsongo Unknow JSONNodeType")
ErrorUnknowType error if you try to use an unknow JSONNodeType
var ErrorValNotPointer = errors.New("jsongo: Val: arguments must be a pointer and not nil")
ErrorValNotPointer error if you try to use Val without a valid pointer
Functions ¶
func UpperCamelCase ¶
UpperCamelCase converts a string to it's upper camel case version.
Types ¶
type JSONNode ¶
type JSONNode struct {
// contains filtered or unexported fields
}
JSONNode Datastructure to build and maintain Nodes
func (*JSONNode) Array ¶
Array Turn this JSONNode to a TypeArray and/or set the array size (reducing size will make you loose data)
func (*JSONNode) At ¶
At helps you move through your node by building them on the fly
val can be string or int only
strings are keys for TypeMap
ints are index in TypeArray (it will make array grow on the fly, so you should start to populate with the biggest index first)*
func (*JSONNode) Copy ¶
Copy Will set this node like the one in argument. this node must be of type TypeUndefined
if deepCopy is true we will copy all the children recursively else we will share the children
return the current JSONNode
func (*JSONNode) DebugPrint ¶
DebugPrint Print a JSONNode as json withindent
func (*JSONNode) DebugProspect ¶
DebugProspect Print all the data the we ve got on a node and all it s children
func (*JSONNode) Get ¶
func (that *JSONNode) Get() interface{}
Get Return value of a TypeValue as interface{}
func (*JSONNode) GetKeys ¶
func (that *JSONNode) GetKeys() []interface{}
GetKeys Return a slice interface that represent the keys to use with the At fonction (Works only on TypeMap and TypeArray)
func (*JSONNode) GetType ¶
func (that *JSONNode) GetType() JSONNodeType
GetType Is use to Get the Type of a node
func (*JSONNode) Len ¶
Len Return the length of the current Node
if TypeUndefined return 0
if TypeValue return 1
if TypeArray return the size of the array
if TypeMap return the size of the map
func (*JSONNode) Map ¶
Map Turn this JSONNode to a TypeMap and/or Create a new element for key if necessary and return it
func (*JSONNode) MarshalJSON ¶
MarshalJSON Make JSONNode a Marshaler Interface compatible
func (*JSONNode) MustGetBool ¶ added in v1.0.1
MustGetBool Return value of a TypeValue as bool will panic if cant convert the internal value or if the node is not a TypeValue
func (*JSONNode) MustGetFloat32 ¶ added in v1.0.1
MustGetFloat32 Return value of a TypeValue as float32 will panic if cant convert the internal value or if the node is not a TypeValue
func (*JSONNode) MustGetFloat64 ¶ added in v1.0.1
MustGetFloat64 Return value of a TypeValue as float64 will panic if cant convert the internal value or if the node is not a TypeValue
func (*JSONNode) MustGetInt ¶ added in v1.0.1
MustGetInt Return value of a TypeValue as int will panic if cant convert the internal value or if the node is not a TypeValue
func (*JSONNode) MustGetInt8 ¶ added in v1.0.1
MustGetInt8 Return value of a TypeValue as int8 will panic if cant convert the internal value or if the node is not a TypeValue
func (*JSONNode) MustGetInt16 ¶ added in v1.0.1
MustGetInt16 Return value of a TypeValue as int16 will panic if cant convert the internal value or if the node is not a TypeValue
func (*JSONNode) MustGetInt32 ¶ added in v1.0.1
MustGetInt32 Return value of a TypeValue as int32 will panic if cant convert the internal value or if the node is not a TypeValue
func (*JSONNode) MustGetInt64 ¶ added in v1.0.1
MustGetInt64 Return value of a TypeValue as int64 will panic if cant convert the internal value or if the node is not a TypeValue
func (*JSONNode) MustGetString ¶ added in v1.0.1
MustGetString Return value of a TypeValue as string will panic if cant convert the internal value or if the node is not a TypeValue
func (*JSONNode) MustGetUint ¶ added in v1.0.1
MustGetUint Return value of a TypeValue as uint will panic if cant convert the internal value or if the node is not a TypeValue
func (*JSONNode) MustGetUint8 ¶ added in v1.0.1
MustGetUint8 Return value of a TypeValue as uint8 will panic if cant convert the internal value or if the node is not a TypeValue
func (*JSONNode) MustGetUint16 ¶ added in v1.0.1
MustGetUint16 Return value of a TypeValue as uint16 will panic if cant convert the internal value or if the node is not a TypeValue
func (*JSONNode) MustGetUint32 ¶ added in v1.0.1
MustGetUint32 Return value of a TypeValue as uint32 will panic if cant convert the internal value or if the node is not a TypeValue
func (*JSONNode) MustGetUint64 ¶ added in v1.0.1
MustGetUint64 Return value of a TypeValue as uint64 will panic if cant convert the internal value or if the node is not a TypeValue
func (*JSONNode) Print ¶
func (that *JSONNode) Print()
Print Print all the data the we ve got on a node and all it s children as a go struct :) (FOR DEV PURPOSE)
func (*JSONNode) SetType ¶
func (that *JSONNode) SetType(t JSONNodeType) *JSONNode
SetType Is use to set the Type of a node and return the current Node you are working on
func (*JSONNode) UnmarshalDontExpand ¶
UnmarshalDontExpand set or not if Unmarshall will generate anything in that JSONNode and its children
val: will change the expanding rules for this node
- The type wont be change for any type
- Array wont grow
- New keys wont be added to Map
- Values set to nil "*.Val(nil)*" will be turn into the type decide by Json
- It will respect any current mapping and will return errors if needed
recurse: if true, it will set all the children of that JSONNode with val
func (*JSONNode) UnmarshalJSON ¶
UnmarshalJSON Make JSONNode a Unmarshaler Interface compatible
type JSONNodeType ¶
type JSONNodeType uint
JSONNodeType is used to set, check and get the inner type of a JSONNode
const ( //TypeUndefined is set by default for empty JSONNode TypeUndefined JSONNodeType = iota //TypeMap is set when a JSONNode is a Map TypeMap //TypeArray is set when a JSONNode is an Array TypeArray //TypeValue is set when a JSONNode is a Value Node TypeValue )
func (JSONNodeType) String ¶
func (i JSONNodeType) String() string
