json.loads converts decimal points to 'e' in python json.loads converts decimal points to 'e' in python json json

json.loads converts decimal points to 'e' in python


This is the way python shows floats

price = 0.00000026print(price)

outputs: 2.6e-07you can print it this way if you want to see it normal:

print('{0:.8f}'.format(price))

ouputs: 0.00000026


Your value is parsed as a Decimal, it's just shown in an exponential form because it's more compact:

import jsonimport decimal>>> x = json.loads('{"a":0.00000000000000026}', parse_float=decimal.Decimal)>>> repr(x)"{'a': Decimal('2.6E-16')}"

You can see that the precision is preserved, though, unlike with a float:

>>> x['a'] + 1Decimal('1.00000000000000026')>>> 1 + 2.6e-161.0000000000000002

So everything works as expected.