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
✨ Update ORJSONResponse
to support non str
keys and serializing Numpy arrays
#3892
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide any tests for that.
@adam-tokarski done |
tests/test_default_response_class.py
Outdated
@app.get("/orjson_non_str_keys") | ||
def get_orjson_non_str_keys(): | ||
key = quoted_name("msg") | ||
return {key: "Hello World"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't that key
still a string? It seems like it should be working even before the fix (I didn't check that though).
Also, you could provide a test with some integer as a key maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it is a string, but not a str
type, orjson not support without option=orjson.OPT_NON_STR_KEYS
'integer as a key' is coming
@adam-tokarski done |
ORJSONResponse
to support non str
keys and serializing Numpy arrays
Great, thank you @baby5! And thanks for adding tests! 🍰 And thanks @adam-tokarski for the help and review! ☕ I updated the implementation a bit to include serializing Numpy arrays and testing the included This will be available in the next release, in the next hours, FastAPI |
📝 Docs preview for commit 37621c8 at: https://6311d5f220a23774734691d2--fastapi.netlify.app |
Codecov Report
@@ Coverage Diff @@
## master #3892 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 537 538 +1
Lines 13856 13870 +14
=========================================
+ Hits 13856 13870 +14
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
What is the status of this issue regarding support for NumPy arrays ? |
the detail see: ijl/orjson#197
my case is
<class 'sqlalchemy.sql.elements.quoted_name'>