diff options
author | 2023-06-01 22:20:16 +0100 | |
---|---|---|
committer | 2023-06-01 22:20:16 +0100 | |
commit | 55aacaf4b07c1921061245cbaa3d307e97cf3c29 (patch) | |
tree | d969c5d9728566de1e794e19c5b19d3b660f790e /vendor/github.com/bytedance/sonic/ast/node.go | |
parent | [chore/frontend] refactor header templating, add apple-touch-icon (#1850) (diff) | |
download | gotosocial-55aacaf4b07c1921061245cbaa3d307e97cf3c29.tar.xz |
[chore]: Bump github.com/gin-gonic/gin from 1.9.0 to 1.9.1 (#1855)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Diffstat (limited to 'vendor/github.com/bytedance/sonic/ast/node.go')
-rw-r--r-- | vendor/github.com/bytedance/sonic/ast/node.go | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/vendor/github.com/bytedance/sonic/ast/node.go b/vendor/github.com/bytedance/sonic/ast/node.go index 0d37baf12..6b5ad8a3e 100644 --- a/vendor/github.com/bytedance/sonic/ast/node.go +++ b/vendor/github.com/bytedance/sonic/ast/node.go @@ -1541,13 +1541,19 @@ var ( emptyObjectNode = Node{t: types.V_OBJECT} ) -// NewRaw creates a node of raw json, and decides its type by first char. +// NewRaw creates a node of raw json. +// If the input json is invalid, NewRaw returns a error Node. func NewRaw(json string) Node { - if json == "" { - panic("empty json string") + parser := NewParser(json) + start, err := parser.skip() + if err != 0 { + return *newError(err, err.Message()) + } + it := switchRawType(parser.s[start]) + if it == _V_NONE { + return Node{} } - it := switchRawType(json[0]) - return newRawNode(json, it) + return newRawNode(parser.s[start:parser.p], it) } // NewAny creates a node of type V_ANY if any's type isn't Node or *Node, |