Documentation ¶
Index ¶
- Constants
- Variables
- func Fuzz(data []byte) int
- func Release(root *Root)
- type Last
- type Node
- func (n *Node) AddField(name string) *Node
- func (n *Node) AppendElement() *Node
- func (n *Node) AsArray() []*Node
- func (n *Node) AsBool() bool
- func (n *Node) AsBytes() []byte
- func (n *Node) AsEscapedString() string
- func (n *Node) AsField(field string) *Node
- func (n *Node) AsFieldValue() *Node
- func (n *Node) AsFields() []*Node
- func (n *Node) AsFloat() float64
- func (n *Node) AsInt() int
- func (n *Node) AsString() string
- func (n *Node) Dig(path ...string) *Node
- func (n *Node) DigStrict(path ...string) (*StrictNode, error)
- func (n *Node) Encode(out []byte) []byte
- func (n *Node) EncodeToByte() []byte
- func (n *Node) EncodeToString() string
- func (n *Node) InStrictMode() *StrictNode
- func (n *Node) InsertElement(pos int) *Node
- func (n *Node) IsArray() bool
- func (n *Node) IsFalse() bool
- func (n *Node) IsField() bool
- func (n *Node) IsNil() bool
- func (n *Node) IsNull() bool
- func (n *Node) IsNumber() bool
- func (n *Node) IsObject() bool
- func (n *Node) IsString() bool
- func (n *Node) IsTrue() bool
- func (n *Node) MergeWith(node *Node) *Node
- func (n *Node) MutateToBool(value bool) *Node
- func (n *Node) MutateToEscapedString(value string) *Node
- func (n *Node) MutateToField(value string) *Node
- func (n *Node) MutateToFloat(value float64) *Node
- func (n *Node) MutateToInt(value int) *Node
- func (n *Node) MutateToJSON(json string) *Node
- func (n *Node) MutateToNode(node *Node) *Node
- func (n *Node) MutateToNull(value bool) *Node
- func (n *Node) MutateToObject() *Node
- func (n *Node) MutateToString(value string) *Node
- func (n *Node) Suicide()
- type Root
- func (r *Root) BuffCap() int
- func (r *Root) DecodeBytes(jsonBytes []byte) error
- func (r *Root) DecodeBytesAdditional(jsonBytes []byte) (*Node, error)
- func (r *Root) DecodeString(json string) error
- func (r *Root) DecodeStringAdditional(json string) (*Node, error)
- func (r *Root) PullSize() int
- func (r *Root) ReleaseBufMem()
- func (r *Root) ReleaseMem()
- func (r *Root) ReleasePoolMem()
- type StrictNode
- func (n *StrictNode) AsArray() ([]*Node, error)
- func (n *StrictNode) AsBool() (bool, error)
- func (n *StrictNode) AsBytes() ([]byte, error)
- func (n *StrictNode) AsEscapedString() (string, error)
- func (n *StrictNode) AsField(field string) (*Node, error)
- func (n *StrictNode) AsFieldValue() (*Node, error)
- func (n *StrictNode) AsFields() ([]*Node, error)
- func (n *StrictNode) AsFloat() (float64, error)
- func (n *StrictNode) AsInt() (int, error)
- func (n *StrictNode) AsString() (string, error)
- type Type
Constants ¶
const (
FlagFieldMap = 1 << 0
)
Variables ¶
var ( StartNodePoolSize = 16 // decode errors ErrEmptyJSON = errors.New("json is empty") ErrUnexpectedJSONEnding = errors.New("unexpected ending of json") ErrUnexpectedEndOfString = errors.New("unexpected end of string") ErrUnexpectedEndOfTrue = errors.New("unexpected end of true") ErrUnexpectedEndOfFalse = errors.New("unexpected end of false") ErrUnexpectedEndOfNull = errors.New("unexpected end of null") ErrUnexpectedEndOfObjectField = errors.New("unexpected end of object field") ErrExpectedObjectField = errors.New("expected object field") ErrExpectedObjectFieldSeparator = errors.New("expected object field separator") ErrExpectedValue = errors.New("expected value") ErrExpectedComma = errors.New("expected comma") // api errors ErrRootIsNil = errors.New("root is nil") ErrNotFound = errors.New("node isn't found") ErrNotObject = errors.New("node isn't an object") ErrNotArray = errors.New("node isn't an array") ErrNotBool = errors.New("node isn't a bool") ErrNotString = errors.New("node isn't a string") ErrNotNumber = errors.New("node isn't a number") ErrNotField = errors.New("node isn't an object field") )
Functions ¶
Types ¶
type Node ¶
type Node struct { Type Type // contains filtered or unexported fields }
func (*Node) AppendElement ¶
func (*Node) AsEscapedString ¶
func (*Node) AsFieldValue ¶
func (*Node) Encode ¶
Encode legendary insane encode function uses already created byte buffer to place json data so mem allocations may occur only if buffer isn't long enough use it for performance
func (*Node) EncodeToByte ¶
EncodeToByte legendary insane encode function slow because it allocates new byte buffer on every call use Encode to reuse already created buffer and gain more performance
func (*Node) EncodeToString ¶
EncodeToString legendary insane encode function slow because it allocates new string on every call use Encode to reuse already created buffer and gain more performance
func (*Node) InStrictMode ¶
func (n *Node) InStrictMode() *StrictNode
func (*Node) InsertElement ¶
func (*Node) MutateToBool ¶
func (*Node) MutateToEscapedString ¶
func (*Node) MutateToField ¶
func (*Node) MutateToFloat ¶
func (*Node) MutateToInt ¶
func (*Node) MutateToJSON ¶
func (*Node) MutateToNode ¶
MutateToNode it isn't safe function, if you create node cycle, encode() may freeze
func (*Node) MutateToNull ¶
func (*Node) MutateToObject ¶
func (*Node) MutateToString ¶
type Root ¶
type Root struct {
*Node
}
func DecodeBytes ¶
func DecodeString ¶
func (*Root) DecodeBytes ¶
DecodeBytes clear root and decode new JSON useful for reusing root to decode multiple times and reduce allocations
func (*Root) DecodeBytesAdditional ¶
DecodeBytesAdditional doesn't clean root, uses root's node pool to decode JSON
func (*Root) DecodeString ¶
DecodeString clear root and decode new JSON useful for reusing root to decode multiple times and reduce allocations
func (*Root) DecodeStringAdditional ¶
DecodeStringAdditional doesn't clean root, uses root's node pool to decode JSON
func (*Root) ReleaseBufMem ¶
func (r *Root) ReleaseBufMem()
ReleasePoolMem sends internal buffer to GC
func (*Root) ReleaseMem ¶
func (r *Root) ReleaseMem()
ReleaseMem sends node pool and internal buffer to GC useful to reduce memory usage after decoding big JSON
type StrictNode ¶
type StrictNode struct {
*Node
}
func (*StrictNode) AsArray ¶
func (n *StrictNode) AsArray() ([]*Node, error)
func (*StrictNode) AsBool ¶
func (n *StrictNode) AsBool() (bool, error)
func (*StrictNode) AsBytes ¶
func (n *StrictNode) AsBytes() ([]byte, error)
func (*StrictNode) AsEscapedString ¶
func (n *StrictNode) AsEscapedString() (string, error)
func (*StrictNode) AsFieldValue ¶
func (n *StrictNode) AsFieldValue() (*Node, error)
func (*StrictNode) AsFields ¶
func (n *StrictNode) AsFields() ([]*Node, error)
func (*StrictNode) AsFloat ¶
func (n *StrictNode) AsFloat() (float64, error)
func (*StrictNode) AsInt ¶
func (n *StrictNode) AsInt() (int, error)
func (*StrictNode) AsString ¶
func (n *StrictNode) AsString() (string, error)