Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

✨ UpdateORJSONResponse to support nonstr keys and serializing Numpy arrays#3892

Merged
tiangolo merged 8 commits intofastapi:masterfrom
baby5:master
Sep 2, 2022
Merged

✨ UpdateORJSONResponse to support nonstr keys and serializing Numpy arrays#3892
tiangolo merged 8 commits intofastapi:masterfrom
baby5:master

Conversation

@baby5
Copy link
Contributor

the detail see:https://github.com/ijl/orjson/issues/197

my case is<class 'sqlalchemy.sql.elements.quoted_name'>

Copy link

@adam-tokarskiadam-tokarski left a 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.

@baby5
Copy link
ContributorAuthor

@adam-tokarski done

@app.get("/orjson_non_str_keys")
def get_orjson_non_str_keys():
key = quoted_name("msg")
return {key: "Hello World"}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Isn't thatkey 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?

Copy link
ContributorAuthor

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 astr type, orjson not support withoutoption=orjson.OPT_NON_STR_KEYS
'integer as a key' is coming

@baby5
Copy link
ContributorAuthor

@adam-tokarski done

@tiangolotiangolo changed the titleUpdate orjson support non str keys✨ UpdateORJSONResponse to support nonstr keys and serializing Numpy arraysSep 2, 2022
@tiangolo
Copy link
Member

tiangolo commentedSep 2, 2022
edited
Loading

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 includedORJSONResponse, because those tests test a custom one that doesn't include these changes.

This will be available in the next release, in the next hours, FastAPI0.82.0. 🎉

baby5 reacted with laugh emoji

@github-actions
Copy link
Contributor

📝 Docs preview for commit37621c8 at:https://6311d5f220a23774734691d2--fastapi.netlify.app

@tiangolotiangoloenabled auto-merge (squash)September 2, 2022 10:16
@codecov
Copy link

codecovbot commentedSep 2, 2022
edited
Loading

Codecov Report

Merging#3892 (f136624) intomaster (173b891) willnot change coverage.
The diff coverage is100.00%.

@@            Coverage Diff            @@##            master     #3892   +/-   ##=========================================  Coverage   100.00%   100.00%           =========================================  Files          537       538    +1       Lines        13856     13870   +14     =========================================+ Hits         13856     13870   +14
Impacted FilesCoverage Δ
fastapi/responses.py100.00% <100.00%> (ø)
tests/test_orjson_response_class.py100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell ushow you rate us. Have a feature suggestion?Share it here.

@tiangolotiangolo merged commit7250c19 intofastapi:masterSep 2, 2022
@NikosAlexandris
Copy link

What is the status of this issue regarding support for NumPy arrays ?

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

1 more reviewer

@adam-tokarskiadam-tokarskiadam-tokarski approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@baby5@tiangolo@NikosAlexandris@adam-tokarski

[8]ページ先頭

©2009-2026 Movatter.jp