X Tutup
The Wayback Machine - https://web.archive.org/web/20200708012720/https://github.com/hugapi/hug/issues/716
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

Document how to extend json serialization #716

Open
Omniflux opened this issue Jan 5, 2019 · 0 comments
Open

Document how to extend json serialization #716

Omniflux opened this issue Jan 5, 2019 · 0 comments

Comments

@Omniflux
Copy link
Contributor

@Omniflux Omniflux commented Jan 5, 2019

Not sure where to add this in the documentation, but if you get an error such as this when trying to output

TypeError: Type <class 'uuid.UUID'> not serializable

You can add new types to the json converter like this

from uuid import UUID
@hug.output_format.json_convert(UUID)
def uuid_stringable(item):
    return str(item)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.
X Tutup