Teks sumber — English
Terjemahan — Bahasa Indonesia
If set, a function that is called with one of the following strings: ``'-Infinity'``, ``'Infinity'``, or ``'NaN'``. This can be used to raise an exception if invalid JSON numbers are encountered. Default ``None``.
number (int)
bilangan (int)
number (real)
bilangan (real)
*parse_constant* is an optional function that will be called with one of the following strings: ``'-Infinity'``, ``'Infinity'``, ``'NaN'``. This can be used to raise an exception if invalid JSON numbers are encountered.
number
number
Infinite and NaN number values are accepted and output;
Infinite and NaN Number Values
The RFC does not permit the representation of infinite or NaN number values. Despite that, by default, this module accepts and outputs ``Infinity``, ``-Infinity``, and ``NaN`` as if they were valid JSON number literal values::
The old version of JSON specified by the obsolete :rfc:`4627` required that the top-level value of a JSON text must be either a JSON object or array (Python :class:`dict` or :class:`list`), and could not be a JSON null, boolean, number, or string value. :rfc:`7159` removed that restriction, and this module does not and has never implemented that restriction in either its serializer or its deserializer.
the range and precision of JSON numbers
When serializing to JSON, beware any such limitations in applications that may consume your JSON. In particular, it is common for JSON numbers to be deserialized into IEEE 754 double precision numbers and thus subject to that representation's range and precision limitations. This is especially relevant when serializing Python :class:`int` values of extremely large magnitude, or when serializing instances of "exotic" numerical types such as :class:`decimal.Decimal`.