Replace django.utils.simplejson which handles decimal encoding?

With undo and delete django.utils.simplejson

in 1.7, the proposed replacement shortcut is inline module json

. However, the embedded application does not handle field encoding Decimal

when used dumps()

for eg simplejson

. Using django.core.serializers.json.DjangoJSONEncoder

ie

>>> string = json.dumps({"x", Decimal("100.000000")}, cls=DjangoJSONEncoder)
>>> '{"x": "100.000000"}'

      

seems to convert decimal string to string before encoding, whereas

>>> string = simplejson.dumps({"x", Decimal("100.000000")})
>>> '{"x": 100.000000}'

      

Is there an exact replacement?

+3


source to share


1 answer


The best match I have found for this looks like ujson , it handles decimals just fine.



0


source







All Articles