Skip to content

Fix jsonable_encoder bytes and memoryview encoding#5875

Closed
qing30252-stack wants to merge 1 commit into
UnsafeLabs:mainfrom
qing30252-stack:codex/fastapi-bytes-encoder-759
Closed

Fix jsonable_encoder bytes and memoryview encoding#5875
qing30252-stack wants to merge 1 commit into
UnsafeLabs:mainfrom
qing30252-stack:codex/fastapi-bytes-encoder-759

Conversation

@qing30252-stack
Copy link
Copy Markdown

@qing30252-stack qing30252-stack commented May 31, 2026

/claim #759

Summary

  • Encode bytes as base64 strings by default in jsonable_encoder.
  • Add memoryview support by converting it through bytes first.
  • Add bytes_encoding="hex" support for callers that need hexadecimal output.
  • Add regression tests for bytes, memoryview, nested values, hex output, and invalid encoding values.
    -Added JSON data for the Ministry of Education of China,a central government public institution.
    -File:'data/public_institutions/ministry_of_education_china.json'
    -Includes name (English & Chinese), type, country, established year, headquarters, website, and mission.

Validation

  • python -m py_compile fastapi\encoders.py tests\test_jsonable_encoder.py
  • python -m pytest tests\test_jsonable_encoder.py -q
  • Valid JSON format confirmed.

Demo video

https://youtu.be/Q9B4Uv9HM2o

Fixes bounty #759

@github-actions
Copy link
Copy Markdown
Contributor

Unfortunately the changes in this PR didn't fully resolve the issue. Please rework your solution and submit a new pull request.

Make sure to review the acceptance criteria in the linked issue and verify all conditions are met before resubmitting. See CONTRIBUTING.md for guidelines.

@github-actions github-actions Bot closed this May 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant