Skip to content
Commit 81b12994 authored by Laurent Bachelier's avatar Laurent Bachelier 🐧 Committed by Romain Bignon
Browse files

json: Force Decimal as str with simplejson

simplejson has an internal way of formatting Decimal so it bypasses our
formatter.
Since weboob often deals with money, floats are not a good idea.

Previousl:
Decimal('1.1') => 1.1 with simplejson+WeboobEncoder
Decimal('1.1') => '1.1' with json+WeboobEncoder
Now both give '1.1'.

Under simplejson:
Using dump(cls=...) always initialize the Encoder class with the
use_decimal=True argument (unless the argument is provided in the dump
function, but that requires a lot of alteration in Weboob, and I would
rather remove simplejson support altogether). So when present, we force it.

Under json:
There is no use_decimal, so we already go to the default() method of the
Encoder.
parent 48cb8122
Pipeline #278636030 failed with stages
in 2 minutes and 30 seconds
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment