mirror of
https://github.com/ii64/sonic.git
synced 2026-06-20 16:45:22 +08:00
* feat:(ast) add fallback api on `not-amd64` env * test: add native `linux-arm64` CI * opt: just skip number chars whne `decodeFloat64` * fmt * fix: check EOF
62 lines
No EOL
1.2 KiB
Go
62 lines
No EOL
1.2 KiB
Go
//go:build !amd64
|
|
// +build !amd64
|
|
|
|
package ast
|
|
|
|
import (
|
|
`encoding/base64`
|
|
`encoding/json`
|
|
|
|
`github.com/bytedance/sonic/internal/native/types`
|
|
`github.com/bytedance/sonic/internal/rt`
|
|
)
|
|
|
|
func quote(buf *[]byte, val string) {
|
|
quoteString(buf, val)
|
|
}
|
|
|
|
func unquote(src string) (string, types.ParsingError) {
|
|
sp := rt.IndexChar(src, -1)
|
|
out, ok := unquoteBytes(rt.BytesFrom(sp, len(src)+2, len(src)+2))
|
|
if !ok {
|
|
return "", types.ERR_INVALID_ESCAPE
|
|
}
|
|
return rt.Mem2Str(out), 0
|
|
}
|
|
|
|
|
|
|
|
func decodeBase64(src string) ([]byte, error) {
|
|
return base64.StdEncoding.DecodeString(src)
|
|
}
|
|
|
|
func encodeBase64(src []byte) string {
|
|
return base64.StdEncoding.EncodeToString(src)
|
|
}
|
|
|
|
func (self *Parser) decodeValue() (val types.JsonState) {
|
|
e, v := decodeValue(self.s, self.p)
|
|
if e < 0 {
|
|
return v
|
|
}
|
|
self.p = e
|
|
return v
|
|
}
|
|
|
|
func (self *Parser) skip() (int, types.ParsingError) {
|
|
e, s := skipValue(self.s, self.p)
|
|
if e < 0 {
|
|
return self.p, types.ParsingError(-e)
|
|
}
|
|
self.p = e
|
|
return s, 0
|
|
}
|
|
|
|
func (self *Node) encodeInterface(buf *[]byte) error {
|
|
out, err := json.Marshal(self.packAny())
|
|
if err != nil {
|
|
return err
|
|
}
|
|
*buf = append(*buf, out...)
|
|
return nil
|
|
} |