summaryrefslogtreecommitdiff
path: root/compat/json/compat_test.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@datawire.io>2022-08-14 20:52:06 -0600
committerLuke Shumaker <lukeshu@datawire.io>2022-08-15 00:28:47 -0600
commit58b7df5e9f1c0d4858528f326440599620a8c1fb (patch)
treedcbe104b42ff22debe4adf767ff1fe69785aa394 /compat/json/compat_test.go
parent25d0b8365020ef4051dffd4f7704328402914613 (diff)
Create a compat/json compatibility library
Diffstat (limited to 'compat/json/compat_test.go')
-rw-r--r--compat/json/compat_test.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/compat/json/compat_test.go b/compat/json/compat_test.go
new file mode 100644
index 0000000..399ff02
--- /dev/null
+++ b/compat/json/compat_test.go
@@ -0,0 +1,37 @@
+// Copyright (C) 2022 Luke Shumaker <lukeshu@lukeshu.com>
+//
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+package json
+
+import (
+ "bytes"
+
+ "git.lukeshu.com/go/lowmemjson/internal"
+)
+
+var parseTag = internal.ParseTag
+
+const (
+ startDetectingCyclesAfter = 1000
+)
+
+func isSpace(c byte) bool {
+ switch c {
+ case 0x0020, 0x000A, 0x000D, 0x0009:
+ return true
+ default:
+ return false
+ }
+}
+
+type encodeState struct {
+ bytes.Buffer
+}
+
+func (es *encodeState) string(str string, _ bool) {
+ internal.EncodeStringFromString(&es.Buffer, str)
+}
+func (es *encodeState) stringBytes(str []byte, _ bool) {
+ internal.EncodeStringFromBytes(&es.Buffer, str)
+}