On Sun, Aug 11, 2019, at 20:42, Chris Angelico wrote: > class float: > def __json__(self): > if math.isfinite(self): return str(self) > return "null"
Er, to be clear, the current JSON decoder returns 'Infinity', '-Infinity', or 'NaN', which are invalid JSON, not null. This behavior (vs raising an exception) is governed by a flag. I'm mainly bringing this up to point out that the concerns about a raw protocol being able to generate invalid JSON seem somewhat overblown and that "people should be able to generate invalid JSON if they want to" is not without precedent. _______________________________________________ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/37TVGQOXHCJRMK6JSXPOZVMDOTIDHNEA/ Code of Conduct: http://python.org/psf/codeofconduct/
