jansson icon indicating copy to clipboard operation
jansson copied to clipboard

feature request: parse_float callback, as in Python's json loader

Open argriffing opened this issue 9 years ago • 3 comments

Python lets you do

>>> import decimal
>>> json.loads('1.1', parse_float=decimal.Decimal)
Decimal('1.1')

I would be tempted to use something like this, except I would read them as flint2 fmpq rational data types. On the other hand I guess it would not work well with jansson's API. Also I could imagine it might break JSON semantics if things that look like floats are not interpreted as double precision IEEE floating point numbers, so maybe it's just a bad idea.

argriffing avatar May 26 '16 22:05 argriffing

I see this is related to https://github.com/akheron/jansson/pull/158. I'd use it for scientific computing instead of for bitcoin or financial data, but that PR would work for me.

argriffing avatar May 26 '16 22:05 argriffing

Maybe also related to this bignum issue https://github.com/akheron/jansson/issues/69

argriffing avatar May 26 '16 22:05 argriffing

#69 is the way to go. Nobody just ever finished the work.

akheron avatar May 30 '16 08:05 akheron