blob: 2cb1e87f685f68d442edc71e587afc71e7c99059 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
// Copyright (C) 2022 Luke Shumaker <lukeshu@lukeshu.com>
//
// SPDX-License-Identifier: GPL-2.0-or-later
package json
import (
"bytes"
"io"
"git.lukeshu.com/go/lowmemjson"
"git.lukeshu.com/go/lowmemjson/internal"
)
var parseTag = internal.ParseTag
type scanner = lowmemjson.ReEncoder
func checkValid(in []byte, scan *lowmemjson.ReEncoder) error {
scan.Out = io.Discard
return reencode(in, scan)
}
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)
}
|