[issue16535] json encoder unable to handle decimal

2022-03-03 Thread Luca Lesinigo
Change by Luca Lesinigo : -- nosy: +luca.lesinigo ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mai

[issue16535] json encoder unable to handle decimal

2020-12-21 Thread Raymond Hettinger
Raymond Hettinger added the comment: > I wonder if adding something similar to what `simplejson` uses > (i.e. explicitly specifying in `json.dump(s)` how to > serialize `decimal.Decimal`) could be acceptable. +1 for this approach. For financial applications, we need the recommended solution

[issue16535] json encoder unable to handle decimal

2020-12-20 Thread mike bayer
Change by mike bayer : -- nosy: +zzzeek ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.o

[issue16535] json encoder unable to handle decimal

2019-08-08 Thread Richard Musil
Richard Musil added the comment: It looks like I am resurrecting an old item, but I have been just hit by this and was directed to this issue (https://mail.python.org/archives/list/python-id...@python.org/thread/WT6Z6YJDEZXKQ6OQLGAPB3OZ4OHCTPDU/) I wonder if adding something similar to what

[issue16535] json encoder unable to handle decimal

2017-03-05 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: The trick from msg176158 no longer works since issue26719. -- ___ Python tracker ___ ___ Python-bu

[issue16535] json encoder unable to handle decimal

2016-08-31 Thread Mads Jensen
Mads Jensen added the comment: Hi @cvrebert and team - do you know if this was ever implemented. It seems that it is still an issue for financial applications, and that the solution proposed would be relevant and helpful. -- nosy: +mjensen ___ Pytho

[issue16535] json encoder unable to handle decimal

2014-10-14 Thread Stefan Krah
Changes by Stefan Krah : -- nosy: -skrah ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.o

[issue16535] json encoder unable to handle decimal

2014-07-26 Thread Chris Rebert
Chris Rebert added the comment: > 1) JSON just support floats If you read the JSON standards documents, you'll see that this isn't accurate. Regardless, a general solution for non-built-in numeric types does seem preferable. -- ___ Python tracker

[issue16535] json encoder unable to handle decimal

2014-07-26 Thread Christian Heimes
Christian Heimes added the comment: I'm EuroPython 2014 in Berlin. Ralph has approached me and asked me about progress on the progress of this patch. I'm reluctant to implement a special case for decimals for two reasons: 1) JSON just support floats and decimals are IMHO incompatible with floa

[issue16535] json encoder unable to handle decimal

2014-07-26 Thread Ralph Heinkel
Changes by Ralph Heinkel : -- nosy: +christian.heimes ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://m

[issue16535] json encoder unable to handle decimal

2014-03-24 Thread Stefan Krah
Stefan Krah added the comment: I think we should really apply #19232. At least that would take care of the import issue. -- ___ Python tracker ___ ___

[issue16535] json encoder unable to handle decimal

2014-03-24 Thread Antoine Pitrou
Antoine Pitrou added the comment: The patch isn't really ok, IMO. It forcibly imports the decimal module and then looks up the type there. The decimal module is a rather large one and it shouldn't get imported if it doesn't get used. I think it would be better to rely on the __float__ special

[issue16535] json encoder unable to handle decimal

2014-03-24 Thread Chris Rebert
Changes by Chris Rebert : -- nosy: +cvrebert ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pytho

[issue16535] json encoder unable to handle decimal

2014-03-13 Thread Éric Araujo
Éric Araujo added the comment: Patch looks good and contains tests for the C and Python code. Documentation is missing (a note to tell that json.dump converts decimal.Decimal instances to JSON numbers, a versionchanged directive, maybe a link to the doc that explains parse_float=decimal.Decima

[issue16535] json encoder unable to handle decimal

2014-03-13 Thread Éric Araujo
Changes by Éric Araujo : -- hgrepos: -202 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.

[issue16535] json encoder unable to handle decimal

2013-07-07 Thread Ralph Heinkel
Ralph Heinkel added the comment: This patch was implemented on Europython 2013 sprint. It's my first addition to Python core ever so please bear with me if it's not perfect. Decimal support is implemented both in the C and Python JSON code. There is one peculiarity to mention about the Decima

[issue16535] json encoder unable to handle decimal

2013-01-13 Thread Arfrever Frehtes Taifersar Arahesis
Changes by Arfrever Frehtes Taifersar Arahesis : -- nosy: +Arfrever ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscri

[issue16535] json encoder unable to handle decimal

2013-01-13 Thread Antoine Pitrou
Antoine Pitrou added the comment: Decimal numbers should simply be serializable by default. It doesn't make sense to add a specialized option. -- components: +Library (Lib) type: behavior -> enhancement ___ Python tracker

[issue16535] json encoder unable to handle decimal

2012-11-30 Thread Jesús Cea Avión
Changes by Jesús Cea Avión : -- nosy: +jcea ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.

[issue16535] json encoder unable to handle decimal

2012-11-25 Thread Éric Araujo
Éric Araujo added the comment: Thanks for the workaround Serhiy, I stole that and ran with it :) For 3.4 I still think something built-in would be best. -- ___ Python tracker __

[issue16535] json encoder unable to handle decimal

2012-11-23 Thread Mark Dickinson
Mark Dickinson added the comment: Judging by the discussion that Éric points to, and by the various stackoverflow questions on the topic ([1], [2]), this is a common enough need that I think it would make sense to have some support for it in the std. lib. There's a sense in which Decimal is th

[issue16535] json encoder unable to handle decimal

2012-11-23 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: The json module already has too many options. No need for yet one such specialized. >>> class number_str(float): ... def __init__(self, o): ... self.o = o ... def __repr__(self): ... return str(self.o) ... >>> def decimal_serializer(o

[issue16535] json encoder unable to handle decimal

2012-11-22 Thread Stefan Krah
Changes by Stefan Krah : -- nosy: +skrah ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org

[issue16535] json encoder unable to handle decimal

2012-11-22 Thread Éric Araujo
Éric Araujo added the comment: See lengthy discussion that lead to inclusion in simplejson here: http://code.google.com/p/simplejson/issues/detail?id=34 -- ___ Python tracker __

[issue16535] json encoder unable to handle decimal

2012-11-22 Thread Éric Araujo
New submission from Éric Araujo: In 2.7 and other versions, the json module has incomplete support for decimals: >>> json.loads('0.2', parse_float=Decimal) Decimal('0.2') >>> json.dumps(json.loads('0.2', parse_float=Decimal)) Traceback (most recent call last): File "", line 1, in File "/usr