[Python-ideas] Re: adding support for a "raw output" in JSON serializer

2019-08-11 Thread Christopher Barker
On Sat, Aug 10, 2019 at 11:08 PM Greg Ewing wrote: > > I don't think anyone else has come up with, any > > examples other than Decimal that require this "raw" encoding. > > It's possible that someone could have their own custom numeric > type that they want to encode as a JSON number. But if the

[Python-ideas] Re: adding support for a "raw output" in JSON serializer

2019-08-11 Thread David Shawley
On Aug 8, 2019, at 3:55 PM, Chris Angelico wrote: > > There are two broad suggestions that came out of that thread and > others, and I think it may be worth reopening them. > > 1) Should JSONEncoder (the class underlying json.dumps) natively > support decimal.Decimal, and if so, can it avoid im

[Python-ideas] JSON encoder protocol (was Re: adding support for a "raw output" in JSON serializer)

2019-08-11 Thread Chris Angelico
On Mon, Aug 12, 2019 at 10:09 AM David Shawley wrote: > > On Aug 8, 2019, at 3:55 PM, Chris Angelico wrote: > > 2) Should there be a protocol obj.__json__() to return a string > > representation of an object for direct insertion into a JSON file? > > I'm inclined towards the protocol, since there

[Python-ideas] Re: adding support for a "raw output" in JSON serializer

2019-08-11 Thread Christopher Barker
On Sat, Aug 10, 2019 at 11:20 PM Richard Musil wrote: > Christopher, let me go through your summary and add some remarks, > hopefully for the benefit of all (who made it so far) in this conversation: > And more comments from me now :-) > Christopher Barker wrote: > > > TL;DR : I propose that p

[Python-ideas] Re: adding support for a "raw output" in JSON serializer

2019-08-11 Thread Christopher Barker
On Sun, Aug 11, 2019 at 5:12 PM David Shawley wrote: > 1) Should JSONEncoder (the class underlying json.dumps) natively > support decimal.Decimal, and if so, can it avoid importing that module > unnecessarily? > > I think yes on both counts :-) > 2) Should there be a protocol obj.__json__() to r

[Python-ideas] Re: adding support for a "raw output" in JSON serializer

2019-08-11 Thread Chris Angelico
On Mon, Aug 12, 2019 at 3:01 PM Christopher Barker wrote: > > On Sun, Aug 11, 2019 at 5:12 PM David Shawley wrote: >> >> 1) Should JSONEncoder (the class underlying json.dumps) natively >> support decimal.Decimal, and if so, can it avoid importing that module >> unnecessarily? > > I think yes on