On 6/10/2020 9:48 AM, Alex Hall wrote:
On Wed, Jun 10, 2020 at 3:42 PM J. Pic <jpic@yourlabs.org> wrote:
I understand, do you think the python standard library should provide a JSONEncoder and JSONDecoder that supports python standard library objects ?

It would be optional to use, but if you use it then any object from the python standard library will just work.

I think a JSONEncoder for standard types would be nice to have.

 A JSONDecoder is much more complicated. What would it do? Convert every string that looks like an ISO datetime into a Python datetime object? Or convert objects like `{"type": "datetime", "value": "2020-01-01T12:34:56"}`?

The general problem here is that if you're encoding things for a non-python program to use, you can't do something non-standard like the above. And if you're looking for something that only other python programs can use, you're better off using pickle or some other non-JSON format.

That's why these ideas never result in any changes to the stdlib json library.

Eric