The Python3 standard lib for JSON, https://docs.python.org/3/library/json.html, documents the following (emphasis mine):
If allow_nan is false (default: True), then it will be a ValueError to serialize out of range float values (nan, inf, -inf) in strict compliance of the JSON specification. If allow_nan is true, their JavaScript equivalents (NaN, Infinity, -Infinity) will be used.
Further down on the encoder:
If allow_nan is true (the default), then NaN, Infinity, and -Infinity will be encoded as such. This behavior is not JSON specification compliant, but is consistent with most JavaScript based encoders and decoders. Otherwise, it will be a ValueError to encode such floats.
While it is good they allow this as an option for those who are capable of deliberately parsing NaN, why doesn't Python follow the JSON spec as the default?