Skip to content

Review marshalling of Decimal values #52

@amotl

Description

@amotl

About

Based on a comment by @seut,

I think using a float won't work as a Decimal has a 128bit range and thus cannot fit into a float.

this piece of code may want to be reviewed.

def patch_json_encoder():
"""
`Decimal` types have been rendered as strings.
TODO: Upstream to crate-python.
"""
json_encoder_default = CrateJsonEncoder.default
def default(self, o):
if isinstance(o, Decimal):
return float(o)
return json_encoder_default(o)
CrateJsonEncoder.default = default

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions