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 float_hook to json decoder #511

Merged
merged 1 commit into from
Aug 10, 2023
Merged

Add float_hook to json decoder #511

merged 1 commit into from
Aug 10, 2023

Conversation

jcrist
Copy link
Owner

@jcrist jcrist commented Aug 10, 2023

This adds support for a float_hook to the json decoder. If set, this hook will be called to decode any untyped JSON float values from their raw string representations. This may be used to change the default float parsing from returning float values to return decimal.Decimal values again.

Since this is an uncommon option, it's only available on the Decoder, rather than the top-level msgspec.json.decode function.

Fixes #507.

This adds support for a `float_hook` to the json decoder. If set, this
hook will be called to decode any untyped JSON float values from their
raw string representations. This may be used to change the default float
parsing from returning ``float`` values to return ``decimal.Decimal``
values again.

Since this is an uncommon option, it's only available on the Decoder,
rather than the top-level ``msgspec.json.decode`` function.
@jcrist jcrist merged commit 5de1be2 into main Aug 10, 2023
7 checks passed
@jcrist jcrist deleted the add-float-hook branch August 10, 2023 20:29
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.

Support parse_float (or some other name) in msgspec.json.decode
1 participant