Skip to content

feat: add OPT_ENSURE_ASCII functionality, with tests #585

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

DeflateAwning
Copy link

Changes

  • Added orjson.OPT_ENSURE_ASCII functionality, which mirrors the json.dumps(..., ensure_ascii=True) implementation
  • Added a complete grid search test which covers a variety of test objects with all combinations of OPT_ENSURE_ASCII, OPT_INDENT_2, and OPT_SORT_KEYS enabled, comparing back to json.dumps(...) versions of those (see test/test_dumps_indent_ascii.py file).
  • Updated documentation in README to report new functionality.

Notes

  • Note: Platform-specific optimized implementations of the new 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.
  • This is related to Issue Feature Request: Add an 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

  • Update change log. I have not updated the change log yet.
  • I'd recommend a squash-merge into master. Let me know if you'd prefer that I clean up the commit history.

@DeflateAwning
Copy link
Author

Just rebased to your changes in master from yesterday.

@github-actions github-actions bot added the Stale label Jul 24, 2025
@DeflateAwning
Copy link
Author

Just rebased again. Would really appeciate if you could look at this PR for any feedback/blockers!

@github-actions github-actions bot removed the Stale label Jul 25, 2025
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.

1 participant