python-fastjsonschema
python-fastjsonschema copied to clipboard
Support Decimals as numbers
I have a schema like this:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"orderValue": {
"type": "number",
"minimum": 0
},
"commission": {
"type": "number",
"minimum": 0
}
}
}
and data like this:
{
"orderValue": 49.5452999999998,
"commission": 8.334900000001
}
and I would like to parse it like this:
data = json.loads(raw_data, parse_float=decimal.Decimal)
to try and avoid losing any more precision to floating points, however when I feed data into the schema validation it gives me the error
fastjsonschema.exceptions.JsonSchemaValueException: data.orderValue must be number
Is there a way I can have Decimal
s treated like number
s?