mirror of https://github.com/tidwall/gjson.git
Compare commits
4 Commits
6ee9f877d6
...
bbf40bb0e4
Author | SHA1 | Date |
---|---|---|
tidwall | bbf40bb0e4 | |
Josh Baker | 711c6fe9ec | |
Kai A. Hiller | 0f87896dc3 | |
Kai A. Hiller | b622071bec |
4
gjson.go
4
gjson.go
|
@ -1926,6 +1926,10 @@ func AppendJSONString(dst []byte, s string) []byte {
|
|||
if s[i] < ' ' {
|
||||
dst = append(dst, '\\')
|
||||
switch s[i] {
|
||||
case '\b':
|
||||
dst = append(dst, 'b')
|
||||
case '\f':
|
||||
dst = append(dst, 'f')
|
||||
case '\n':
|
||||
dst = append(dst, 'n')
|
||||
case '\r':
|
||||
|
|
|
@ -2578,6 +2578,10 @@ func TestJSONString(t *testing.T) {
|
|||
testJSONString(t, s)
|
||||
testJSONString(t, "R\xfd\xfc\a!\x82eO\x16?_\x0f\x9ab\x1dr")
|
||||
testJSONString(t, "_\xb9\v\xad\xb3|X!\xb6\xd9U&\xa4\x1a\x95\x04")
|
||||
data, _ := json.Marshal("\b\f")
|
||||
if (string(data) == "\"\\b\\f\"") {
|
||||
// Go version 1.22+ encodes "\b" and "\f" correctly.
|
||||
testJSONString(t, "\b\f")
|
||||
rng := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||
start := time.Now()
|
||||
var buf [16]byte
|
||||
|
@ -2587,6 +2591,7 @@ func TestJSONString(t *testing.T) {
|
|||
}
|
||||
testJSONString(t, string(buf[:]))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestIndexAtSymbol(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue