rtyler / py-yajl

py-yajl provides Python bindings for the Yajl JSON encoder/decoder library
http://rtyler.github.com/py-yajl
74 stars 18 forks source link

yajl rounds floats to 6 digits #21

Closed indigoviolet closed 14 years ago

indigoviolet commented 14 years ago
In [12]: yajl.dumps([1.0/3])
Out[12]: '[0.333333]'

In [13]: json.dumps([1.0/3])
Out[13]: '[0.33333333333333331]'

I didn't notice anything in the JSON rfc that set the precision.

indigoviolet commented 14 years ago

This is obviously coming from yajl's yajl_gen_double() function where it's doing an sprintf("%g"), which sets it to 6 digits by default. Is there a way around it?

indigoviolet commented 14 years ago

Also see related issue that I opened on the yajl github: http://github.com/lloyd/yajl/issues#issue/15

rtyler commented 14 years ago

Resolved with SHA: 44e8588f23b058b7ee930120c5a6a453aef10c42