Documentation
¶
Index ¶
- Constants
- func Loads(src string) (int, interface{}, types.ParsingError)
- func LoadsUseNumber(src string) (int, interface{}, types.ParsingError)
- type Iterator
- type ListIterator
- type Node
- func (self *Node) Add(node Node)
- func (self *Node) Array() []interface{}
- func (self *Node) ArrayUseNode() []Node
- func (self *Node) ArrayUseNumber() []interface{}
- func (self *Node) Bool() bool
- func (self *Node) Cap() int
- func (self *Node) Exists() bool
- func (self *Node) Float64() float64
- func (self *Node) Get(key string) *Node
- func (self *Node) GetByPath(path ...interface{}) *Node
- func (self *Node) Index(idx int) *Node
- func (self *Node) Int64() int64
- func (self *Node) Interface() interface{}
- func (self *Node) InterfaceUseNode() interface{}
- func (self *Node) InterfaceUseNumber() interface{}
- func (self Node) IsRaw() bool
- func (self *Node) Len() int
- func (self *Node) Map() map[string]interface{}
- func (self *Node) MapUseNode() map[string]Node
- func (self *Node) MapUseNumber() map[string]interface{}
- func (self *Node) MarshalJSON() ([]byte, error)
- func (self *Node) Number() json.Number
- func (self *Node) Properties() ObjectIterator
- func (self Node) Raw() string
- func (self *Node) Set(key string, node Node)
- func (self *Node) SetByIndex(index int, node Node)
- func (self *Node) String() string
- func (self Node) Type() int
- func (self *Node) UnsafeArray() []Node
- func (self *Node) UnsafeMap() []Pair
- func (self *Node) Unset(key string) (exist bool)
- func (self *Node) UnsetByIndex(index int) (exist bool)
- func (self *Node) Values() ListIterator
- type ObjectIterator
- type Pair
- type Parser
- type Searcher
Constants ¶
const ( V_NONE = 0 V_NULL = 2 V_TRUE = 3 V_FALSE = 4 V_ARRAY = 5 V_OBJECT = 6 V_STRING = 7 V_NUMBER = int(_V_NUMBER) )
Variables ¶
This section is empty.
Functions ¶
func Loads ¶
func Loads(src string) (int, interface{}, types.ParsingError)
Loads parse all json into interface{}
func LoadsUseNumber ¶
func LoadsUseNumber(src string) (int, interface{}, types.ParsingError)
LoadsUseNumber parse all json into interface{}, with numeric nodes casted to json.Number
Types ¶
type ListIterator ¶
type ListIterator struct {
Iterator
}
func (*ListIterator) Next ¶
func (self *ListIterator) Next(v *Node) bool
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
func NewBool ¶
NewBool creates a node of type bool:
If v is true, returns V_TRUE node If v is false, returns V_FALSE node
func NewNumber ¶
NewNumber creates a json.Number node v must be a decimal string complying with RFC8259
func (*Node) Array ¶
func (self *Node) Array() []interface{}
Array loads all indexes of an array node
func (*Node) ArrayUseNode ¶
ArrayUseNode copys both parsed and non-parsed chidren nodes, and indexes them by original order
func (*Node) ArrayUseNumber ¶
func (self *Node) ArrayUseNumber() []interface{}
ArrayUseNumber loads all indexes of an array node, with numeric nodes casted to json.Number
func (*Node) Bool ¶
Bool returns bool value represented by this node
If node type is not types.V_TRUE or types.V_FALSE, or V_RAW (must be a bool json value) it will panic
func (*Node) GetByPath ¶
GetByPath load given path on demands, which only ensure nodes before this path got parsed
func (*Node) Index ¶
Index loads given index of an node on demands, node type can be either V_OBJECT or V_ARRAY
func (*Node) Interface ¶
func (self *Node) Interface() interface{}
Interface loads all children under all pathes from this node, and converts itself as generic go type all numberic nodes are casted to float64
func (*Node) InterfaceUseNode ¶
func (self *Node) InterfaceUseNode() interface{}
InterfaceUseNode clone itself as a new node, or its children as map[string]Node (or []Node)
func (*Node) InterfaceUseNumber ¶
func (self *Node) InterfaceUseNumber() interface{}
InterfaceUseNumber works same with Interface() except numberic nodes are casted to json.Number
func (*Node) Len ¶
Len returns children count of a array|object|string node For partially loaded node, it also works but only counts the parsed children
func (*Node) MapUseNode ¶
MapUseNode scans both parsed and non-parsed chidren nodes, and map them by their keys
func (*Node) MapUseNumber ¶
MapUseNumber loads all keys of an object node, with numeric nodes casted to json.Number
func (*Node) MarshalJSON ¶
func (*Node) Properties ¶
func (self *Node) Properties() ObjectIterator
Properties returns iterator for object's children traversal
func (Node) Raw ¶
Raw returns underlying json string of an raw node, which usually created by Search() api
func (*Node) Set ¶
Set sets the node of given key under object parent If the key doesn't exist, it will be append to the last
func (*Node) SetByIndex ¶
SetByIndex sets the node of given index
The index must within parent array's children
func (Node) Type ¶
Type returns json type represented by the node It will be one of belows:
V_NONE = 0 V_NULL = 2 V_TRUE = 3 V_FALSE = 4 V_ARRAY = 5 V_OBJECT = 6 V_STRING = 7 V_NUMBER = 33
func (*Node) UnsafeArray ¶
ArrayUnsafe exports the underlying pointer to its children array WARN: don't use it unless you know what you are doing
func (*Node) UnsafeMap ¶
MapUnsafe exports the underlying pointer to its children map WARN: don't use it unless you know what you are doing
func (*Node) UnsetByIndex ¶
UnsetByIndex remove the node of given index
func (*Node) Values ¶
func (self *Node) Values() ListIterator
Values returns iterator for array's children traversal
type ObjectIterator ¶
type ObjectIterator struct {
Iterator
}
func (*ObjectIterator) Next ¶
func (self *ObjectIterator) Next(p *Pair) bool
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func (*Parser) ExportError ¶
func (self *Parser) ExportError(err types.ParsingError) error
ExportError converts types.ParsingError to std Error