summaryrefslogtreecommitdiff
path: root/vendor/github.com/bytedance/sonic/api.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/bytedance/sonic/api.go')
-rw-r--r--vendor/github.com/bytedance/sonic/api.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/vendor/github.com/bytedance/sonic/api.go b/vendor/github.com/bytedance/sonic/api.go
index a042476f1..9525b7afd 100644
--- a/vendor/github.com/bytedance/sonic/api.go
+++ b/vendor/github.com/bytedance/sonic/api.go
@@ -68,7 +68,11 @@ type Config struct {
// ValidateString indicates decoder and encoder to valid string values: decoder will return errors
// when unescaped control chars(\u0000-\u001f) in the string value of JSON.
- ValidateString bool
+ ValidateString bool
+
+ // NoValidateJSONMarshaler indicates that the encoder should not validate the output string
+ // after encoding the JSONMarshaler to JSON.
+ NoValidateJSONMarshaler bool
}
var (
@@ -87,6 +91,7 @@ var (
// ConfigFastest is the fastest config of APIs, aiming at speed.
ConfigFastest = Config{
NoQuoteTextMarshaler: true,
+ NoValidateJSONMarshaler: true,
}.Froze()
)
@@ -183,4 +188,9 @@ func Get(src []byte, path ...interface{}) (ast.Node, error) {
// which can reduce unnecessary memory copy.
func GetFromString(src string, path ...interface{}) (ast.Node, error) {
return ast.NewSearcher(src).GetByPath(path...)
-} \ No newline at end of file
+}
+
+// Valid reports whether data is a valid JSON encoding.
+func Valid(data []byte) bool {
+ return ConfigDefault.Valid(data)
+}