mirror of https://github.com/tidwall/sjson.git
Merge branch 'fix-backslashes' of https://github.com/hypoactiv/sjson into hypoactiv-fix-backslashes
This commit is contained in:
commit
ce26db08c7
2
sjson.go
2
sjson.go
|
@ -110,7 +110,7 @@ func parsePath(path string) (pathResult, error) {
|
|||
|
||||
func mustMarshalString(s string) bool {
|
||||
for i := 0; i < len(s); i++ {
|
||||
if s[i] < ' ' || s[i] > 0x7f || s[i] == '"' {
|
||||
if s[i] < ' ' || s[i] > 0x7f || s[i] == '"' || (s[i] == '\\' && i == len(s)-1) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -139,6 +139,7 @@ func TestBasic(t *testing.T) {
|
|||
testRaw(t, setBool, `[true]`, ``, `0`, true)
|
||||
testRaw(t, setBool, `[null]`, ``, `0`, nil)
|
||||
testRaw(t, setString, `{"arr":[1]}`, ``, `arr.-1`, 1)
|
||||
testRaw(t, setString, `{"a":"\\"}`, ``, `a`, "\\")
|
||||
}
|
||||
|
||||
func TestDelete(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue