feat: add OPT_ENSURE_ASCII
functionality, with tests
#585
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
orjson.OPT_ENSURE_ASCII
functionality, which mirrors thejson.dumps(..., ensure_ascii=True)
implementationOPT_ENSURE_ASCII, OPT_INDENT_2, and OPT_SORT_KEYS
enabled, comparing back tojson.dumps(...)
versions of those (seetest/test_dumps_indent_ascii.py
file).Notes
format_escaped_str_ascii
function are not yet implemented. Currently, only a generic implementation is written. While optimizing this function is certainly possible, creating this MVP is what I set out to do first; I'd suggest that it is more than acceptable to merge in its current state.OPT_ENSURE_ASCII
option value #580. I was motivated by JSON-encoding values in such a way that they can be used as values in AWS S3 Metadata values (which only support ASCII characters).Remaining Actions
master
. Let me know if you'd prefer that I clean up the commit history.