4139N/Afor JavaScript Object Notation (JSON)"*.
4139N/AJansson only supports UTF-8 encoded JSON texts. It does not support or
4139N/Aauto-detect any of the other encodings mentioned in the RFC, namely
4139N/AUTF-16LE, UTF-16BE, UTF-32LE or UTF-32BE. Pure ASCII is supported, as
4139N/AJSON strings are mapped to C-style null-terminated character arrays,
4139N/Aand UTF-8 encoding is used internally.
4139N/AAll Unicode codepoints U+0000 through U+10FFFF are allowed in string
4139N/Avalues. However, U+0000 is not allowed in object keys because of API
4139N/AUnicode normalization or any other transformation is never performed
4139N/Aon any strings (string values or object keys). When checking for
4139N/Aequivalence of strings or object keys, the comparison is performed
4139N/Abyte by byte between the original UTF-8 representations of the
4139N/AJSON makes no distinction between real and integer numbers; Jansson
4139N/Adoes. Real numbers are mapped to the ``double`` type and integers to
4139N/Athe ``json_int_t`` type, which is a typedef of ``long long`` or
4139N/A``long``, depending on whether ``long long`` is supported by your
4139N/AA JSON number is considered to be a real number if its lexical
4139N/Arepresentation includes one of ``e``, ``E``, or ``.``; regardless if
4139N/Aits actual numeric value is a true integer (
e.g., all of ``1E6``,
4139N/A``3.0``, ``400E-2``, and ``3.14E3`` are mathematical integers, but
4139N/Awill be treated as real values). With the ``JSON_DECODE_INT_AS_REAL``
4139N/Adecoder flag set all numbers are interpreted as real.
4139N/AAll other JSON numbers are considered integers.
4139N/AWhen encoding to JSON, real values are always represented
4139N/Awith a fractional part;
e.g., the ``double`` value 3.0 will be
4139N/Arepresented in JSON as ``3.0``, not ``3``.
4139N/AOverflow, Underflow & Precision
4139N/A-------------------------------
4139N/AReal numbers whose absolute values are too small to be represented in
4139N/Aa C ``double`` will be silently estimated with 0.0. Thus, depending on
4139N/Aplatform, JSON numbers very close to zero such as 1E-999 may result in
4139N/AReal numbers whose absolute values are too large to be represented in
4139N/Aa C ``double`` will result in an overflow error (a JSON decoding
4139N/Aerror). Thus, depending on platform, JSON numbers like 1E+999 or
4139N/A-1E+999 may result in a parsing error.
4139N/ALikewise, integer numbers whose absolute values are too large to be
4139N/Arepresented in the ``json_int_t`` type (see above) will result in an
4139N/Aoverflow error (a JSON decoding error). Thus, depending on platform,
4139N/AJSON numbers like 1000000000000000 may result in parsing error.
4139N/AParsing JSON real numbers may result in a loss of precision. As long
4139N/Aas overflow does not occur (
i.e. a total loss of precision), the
4139N/Arounded approximate value is silently used. Thus the JSON number
4139N/A1.000000000000000005 may, depending on platform, result in the
4139N/AJSON makes no statement about what a number means; however Javascript
4139N/A(ECMAscript) does state that +0.0 and -0.0 must be treated as being
4139N/Adistinct values,
i.e. -0.0 |not-equal| 0.0. Jansson relies on the
4139N/Aunderlying floating point library in the C environment in which it is
4139N/Acompiled. Therefore it is platform-dependent whether 0.0 and -0.0 will
4139N/Abe distinct values. Most platforms that use the IEEE 754
4139N/Afloating-point standard will support signed zeros.
4139N/ANote that this only applies to floating-point; neither JSON, C, or
4139N/AIEEE support the concept of signed integer zeros.
4139N/A.. |not-equal| unicode:: U+2260
4139N/ANo support is provided in Jansson for any C numeric types other than
4139N/A``json_int_t`` and ``double``. This excludes things such as unsigned
4139N/Atypes, ``long double``, etc. Obviously, shorter types like ``short``,
4139N/A``int``, ``long`` (if ``json_int_t`` is ``long long``) and ``float``
4139N/Aare implicitly handled via the ordinary C type coercion rules (subject
4139N/Ato overflow semantics). Also, no support or hooks are provided for any
4139N/Asupplemental "bignum" type add-on packages.