On Sun, Nov 4, 2018 at 12:02 AM David Shawley firstname.lastname@example.org wrote:
On Nov 2, 2018, at 12:28 PM, Calvin Spealman email@example.com wrote:
Second, JSON is a specific serialization format that explicitly rejects datetime objects in *all* the languages with JSON libraries. You can only use date objects in JSON if you control or understand both serialization and deserialization ends and have an agreed representation.
I would hardly say that "rejects datetime objects in *all* languages..."
If the suggestion here is to have json.dumps(datetime.date(2018,11,4)) to return an encoded string, either by natively supporting it, or by having a protocol which the date object implements, that's fine and reasonable; but json.loads(s) won't return that date object. So, yes, it would be asymmetric. I personally don't have a problem with this (though I also don't have any strong use-cases). Custom encoders and decoders could do this, with or without symmetry. What would it be like to add a couple to the json module that can handle these extra types?