Skip to content
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

✨ Add support for deque objects and children in jsonable_encoder #9433

Merged
merged 5 commits into from
Jun 28, 2023

Conversation

cranium
Copy link
Contributor

@cranium cranium commented Apr 24, 2023

Currently, deques with pydantic models as children are not encoded by jsonable_encoder.

dq = deque([Model(test="test")])

jsonable_encoder(dq)  # => [Model(test="test")]

This PR addresses this by including deque along with the other iterable types (set, generator, etc)

dq = deque([Model(test="test")])

jsonable_encoder(dq)  # => [{"test": "test"}]

@cranium cranium changed the title fix deque of models not encoding child types fix jsonable_encoder not encoding child models for deque Apr 24, 2023
@github-actions
Copy link
Contributor

📝 Docs preview for commit faafda3 at: https://64470059d8fc5b293f54d0fc--fastapi.netlify.app

@github-actions
Copy link
Contributor

📝 Docs preview for commit b81030c at: https://644ab94b383f0b00b860c4ed--fastapi.netlify.app

@tiangolo
Copy link
Member

📝 Docs preview for commit 17152bb at: https://6494b2e083dfc10a6bce7973--fastapi.netlify.app

@tiangolo tiangolo changed the title fix jsonable_encoder not encoding child models for deque ✨ Add support for deque objects and children in jsonable_encoder Jun 28, 2023
@tiangolo
Copy link
Member

Yep, makes sense, thank you! 🚀 ☕

@tiangolo tiangolo merged commit 1f21b16 into fastapi:master Jun 28, 2023
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