-
Notifications
You must be signed in to change notification settings - Fork 126
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
Replace JSON11-produced hex escape codes with unicode escape codes #879
Replace JSON11-produced hex escape codes with unicode escape codes #879
Conversation
JSON11.stringify produces JSON5 documents with hex escape codes (`\x1b`), which aren't standard JSON and cause `JSON.parse` to error. When using JSON11, replace all `\xXX` escape codes with the JSON-compatible equivalent Unicode escape codes (`\u00XX`). Fixes opensearch-project/OpenSearch-Dashboards#7367. Signed-off-by: Will Jordan <[email protected]>
Thanks @wjordan |
Signed-off-by: Will Jordan <[email protected]>
No, the json11 library writes JSON5 documents as expected, the bug is in the serialization code in this repo. See the added unit test which fails without this PR. A feature request for json11 to take an option to |
any update ? |
I'll take a look at this and try @AMoo-Miki 's suggestion. |
looks like JSON11 2.0 has already resolved this issue. Both 2.13.0 and 3.x are using JSON11 2.0. @ycyr are you having trouble with this? would you mind opening a ticket describing what's happening on your end? |
@nhtruong I've just upgrade my cluster to the version 2.18 (I was at the version 2.16) and the problem has been fixed. |
Closing this since this has already been resolved by JSON11 2.x |
Description
Since #784,
JSON11.stringify
produces JSON5 documents with hex escape codes (\x1b
), which aren't standard JSON and causeJSON.parse
to error. When using JSON11 code path, this PR applies a fix to replace all\xXX
escape codes with the JSON-compatible equivalent Unicode escape codes (\u00XX
).This PR adds a unit test verifying the fix by ensuring a round-trip
s.deserialize(s.serialize(obj))
with an object containing long numerals and ANSI escape sequences completes successfully without error.Issues Resolved
Fixes opensearch-project/OpenSearch-Dashboards#7367.
Check List
yarn run lint
doesn't show any errorsBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.