Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encode \b and \f in JSON string as themselves #348

Merged
merged 2 commits into from
Feb 15, 2024

Conversation

V02460
Copy link
Contributor

@V02460 V02460 commented Feb 14, 2024

This PR fixes a test failure by adapting AppendJSONString to follow the new behavior of encoding/json in Go 1.22. The corresponding test case is appended by a check of the \b and \f characters.

Since Go 1.22 the encoding/json library encodes the characters \b and \f as themselves. Before 1.22 they were encoded as \u0008 and \u000c. The new behavior fails TestJSONString:

--- FAIL: TestJSONString (0.00s)
    gjson_test.go:2560: "1&$'\f\x16\xfa\xbah\xc9zz\x89DR\xf3"
                "1\u0026$'\u000c\u0016\ufffd\ufffdh\ufffdzz\ufffdDR\ufffd"
                "1\u0026$'\f\u0016\ufffd\ufffdh\ufffdzz\ufffdDR\ufffd"
                <<< MISMATCH >>>

Go 1.22 release notes: https://tip.golang.org/doc/go1.22#minor_library_changes

@tidwall tidwall merged commit 711c6fe into tidwall:master Feb 15, 2024
1 check passed
@tidwall
Copy link
Owner

tidwall commented Feb 15, 2024

Merged. I had to modify your test to exclude older Go versions ... in case 1.21 users want to pass the tests.
https://github.com/tidwall/gjson/blob/v1.17.1/gjson_test.go#L2582

@tidwall
Copy link
Owner

tidwall commented Feb 15, 2024

and thanks for the PR :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants