Skip to content

Avoid double JSON encoding/decoding#287

Merged
dsp-ant merged 1 commit intomainfrom
avoid-double-json-encoding
Mar 14, 2025
Merged

Avoid double JSON encoding/decoding#287
dsp-ant merged 1 commit intomainfrom
avoid-double-json-encoding

Conversation

@Kludex
Copy link
Copy Markdown
Member

@Kludex Kludex commented Mar 14, 2025

No description provided.

response = Response("Could not find session", status_code=404)
return await response(scope, receive, send)

json = await request.json()
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The json() calls the json module, we can just use the body, and Pydantic's model_validate_json. It's faster.

@Kludex Kludex requested a review from dsp-ant March 14, 2025 12:56
Copy link
Copy Markdown
Member

@dsp-ant dsp-ant left a comment

Choose a reason for hiding this comment

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

TIL!

@dsp-ant dsp-ant merged commit c897868 into main Mar 14, 2025
5 checks passed
@dsp-ant dsp-ant deleted the avoid-double-json-encoding branch March 14, 2025 15:08
@samuelcolvin
Copy link
Copy Markdown
Member

nice!

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.

3 participants