Documentation ¶
Index ¶
- Constants
- Variables
- func AsEfaceFast(iter *NodeIter, ctx *Context) interface{}
- func Decode(s *string, i *int, f uint64, val interface{}) error
- func Parse(data string, opt uint64) error
- func ParseBool(raw string) (bool, error)
- func ParseF64(raw string) (float64, error)
- func ParseI64(raw string) (int64, error)
- func ParseU64(raw string) (uint64, error)
- func Pretouch(vt reflect.Type, opts ...option.CompileOption) error
- func PtrOffset(ptr uintptr, off int64) uintptr
- func SkipNumberFast(json string, start int) (int, error)
- func SkipOneFast(json string, pos int) (string, error)
- func SkipOneFast2(json string, pos *int) (int, error)
- func Unquote(raw string) (string, error)
- func ValidNumberFast(json string) error
- type Array
- type Context
- type Dom
- type ErrorCode
- type MismatchTypeError
- type Node
- func (val Node) Arr() Array
- func (val Node) Array() Array
- func (val *Node) AsArr() (Array, bool)
- func (val Node) AsBool() (bool, bool)
- func (val Node) AsBytesRef(ctx *Context) ([]byte, bool)
- func (node *Node) AsEface(ctx *Context) (interface{}, error)
- func (node *Node) AsEfaceFallback(ctx *Context) (interface{}, error)
- func (val Node) AsF64(ctx *Context) (float64, bool)
- func (self Node) AsI64(ctx *Context) (int64, bool)
- func (node *Node) AsMapEface(ctx *Context, vp unsafe.Pointer) error
- func (node *Node) AsMapString(ctx *Context, vp unsafe.Pointer) error
- func (val Node) AsNumber(ctx *Context) (json.Number, bool)
- func (val *Node) AsObj() (Object, bool)
- func (val Node) AsRaw(ctx *Context) string
- func (node *Node) AsSliceBytes(ctx *Context) ([]byte, error)
- func (node *Node) AsSliceEface(ctx *Context, vp unsafe.Pointer) error
- func (node *Node) AsSliceI32(ctx *Context, vp unsafe.Pointer) error
- func (node *Node) AsSliceI64(ctx *Context, vp unsafe.Pointer) error
- func (node *Node) AsSliceString(ctx *Context, vp unsafe.Pointer) error
- func (node *Node) AsSliceU32(ctx *Context, vp unsafe.Pointer) error
- func (node *Node) AsSliceU64(ctx *Context, vp unsafe.Pointer) error
- func (val Node) AsStr(ctx *Context) (string, bool)
- func (val Node) AsStrRef(ctx *Context) (string, bool)
- func (val Node) AsStringText(ctx *Context) ([]byte, bool)
- func (self Node) AsU64(ctx *Context) (uint64, bool)
- func (val Node) Bool() bool
- func (val *Node) Equal(ctx *Context, lhs string) bool
- func (val Node) F64() float64
- func (val Node) I64() int64
- func (val Node) IsNull() bool
- func (val Node) IsNumber() bool
- func (val Node) IsRawNumber() bool
- func (val Node) IsStr() bool
- func (val Node) Next() uintptr
- func (val Node) NonstrAsNumber(ctx *Context) (json.Number, bool)
- func (val Node) Number(ctx *Context) json.Number
- func (val Node) Obj() Object
- func (val Node) Object() Object
- func (val Node) ParseBool(ctx *Context) (bool, bool)
- func (val Node) ParseF64(ctx *Context) (float64, bool)
- func (val Node) ParseI64(ctx *Context) (int64, bool)
- func (val Node) ParseNumber(ctx *Context) (json.Number, bool)
- func (val Node) ParseString(ctx *Context) (string, bool)
- func (val Node) ParseU64(ctx *Context) (uint64, bool)
- func (val Node) Position() int
- func (val Node) Raw(ctx *Context) string
- func (val Node) StringCopyEsc(ctx *Context) string
- func (val Node) StringRef(ctx *Context) string
- func (val Node) Type() uint8
- func (val Node) U64() uint64
- type NodeIter
- type Object
- type Options
- type Parser
- type SyntaxError
Constants ¶
View Source
const ( // BasicType: 3 bits KNull = 0 // xxxxx000 KBool = 2 // xxxxx010 KNumber = 3 // xxxxx011 KString = 4 // xxxxx100 KRaw = 5 // xxxxx101 KObject = 6 // xxxxx110 KArray = 7 // xxxxx111 // SubType: 2 bits KFalse = (0 << 3) | KBool // xxx00_010, 2 KTrue = (1 << 3) | KBool // xxx01_010, 10 KUint = (0 << 3) | KNumber // xxx00_011, 3 KSint = (1 << 3) | KNumber // xxx01_011, 11 KReal = (2 << 3) | KNumber // xxx10_011, 19 KRawNumber = (3 << 3) | KNumber // xxx11_011, 27 KStringCommon = KString // xxx00_100, 4 KStringEscaped = (1 << 3) | KString // xxx01_100, 12 )
View Source
const ( PosMask = math.MaxUint64 << 32 PosBits = 32 TypeMask = 0xFF TypeBits = 8 ConLenMask = uint64(math.MaxUint32) ConLenBits = 32 )
View Source
const ( OptionUseInt64 = consts.OptionUseInt64 OptionUseNumber = consts.OptionUseNumber OptionUseUnicodeErrors = consts.OptionUseUnicodeErrors OptionDisableUnknown = consts.OptionDisableUnknown OptionCopyString = consts.OptionCopyString OptionValidateString = consts.OptionValidateString )
View Source
const ( SONIC_OK = 0 SONIC_CONTROL_CHAR = 1 SONIC_INVALID_ESCAPED = 2 SONIC_INVALID_NUM = 3 SONIC_FLOAT_INF = 4 SONIC_EOF = 5 SONIC_INVALID_CHAR = 6 SONIC_EXPECT_KEY = 7 SONIC_EXPECT_COLON = 8 SONIC_EXPECT_OBJ_COMMA_OR_END = 9 SONIC_EXPECT_ARR_COMMA_OR_END = 10 SONIC_VISIT_FAILED = 11 SONIC_INVALID_ESCAPED_UTF = 12 SONIC_INVALID_LITERAL = 13 SONIC_STACK_OVERFLOW = 14 )
Variables ¶
View Source
var ParsingErrors = []string{ SONIC_OK: "ok", SONIC_CONTROL_CHAR: "control chars in string", SONIC_INVALID_ESCAPED: "invalid escaped chars in string", SONIC_INVALID_NUM: "invalid number", SONIC_FLOAT_INF: "float infinity", SONIC_EOF: "eof", SONIC_INVALID_CHAR: "invalid chars", SONIC_EXPECT_KEY: "expect a json key", SONIC_EXPECT_COLON: "expect a `:`", SONIC_EXPECT_OBJ_COMMA_OR_END: "expect a `,` or `}`", SONIC_EXPECT_ARR_COMMA_OR_END: "expect a `,` or `]`", SONIC_VISIT_FAILED: "failed in json visitor", SONIC_INVALID_ESCAPED_UTF: "invalid escaped unicodes", SONIC_INVALID_LITERAL: "invalid literal(true/false/null)", SONIC_STACK_OVERFLOW: "json is exceeded max depth 4096, cause stack overflow", }
Functions ¶
func AsEfaceFast ¶
func Pretouch ¶
func Pretouch(vt reflect.Type, opts ...option.CompileOption) error
Pretouch compiles vt ahead-of-time to avoid JIT compilation on-the-fly, in order to reduce the first-hit latency.
Opts are the compile options, for example, "option.WithCompileRecursiveDepth" is a compile option to set the depth of recursive compile for the nested struct type.
func ValidNumberFast ¶
Types ¶
type Context ¶
type Context struct { Parser *Parser Stack bounedStack Utf8Inv bool // contains filtered or unexported fields }
func NewContext ¶
type MismatchTypeError ¶
type MismatchTypeError = errors.MismatchTypeError
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
func (*Node) AsEfaceFallback ¶
func (Node) IsRawNumber ¶
func (Node) StringCopyEsc ¶
type NodeIter ¶
type NodeIter struct {
// contains filtered or unexported fields
}
func NewNodeIter ¶
type SyntaxError ¶
type SyntaxError = errors.SyntaxError
Click to show internal directories.
Click to hide internal directories.