jsonyx.allow.NAN_AND_INFINITY

jsonyx.allow.NAN_AND_INFINITY = frozenset({'nan_and_infinity'})

Allow NaN, Infinity and -Infinity.

>>> import jsonyx as json
>>> import jsonyx.allow
>>> json.loads("[NaN, Infinity, -Infinity]", allow=jsonyx.allow.NAN_AND_INFINITY)
[nan, inf, -inf]
>>> from math import inf, nan
>>> json.dump([nan, inf, -inf], allow=jsonyx.allow.NAN_AND_INFINITY)
[NaN, Infinity, -Infinity]

Note

Decimal("sNan") can’t be (de)serialised this way.