4139N/A.. highlight:: c
4139N/A
4139N/A******************
4139N/AUpgrading from 1.x
4139N/A******************
4139N/A
4139N/AThis chapter lists the backwards incompatible changes introduced in
4139N/AJansson 2.0, and the steps that are needed for upgrading your code.
4139N/A
4139N/A**The incompatibilities are not dramatic.** The biggest change is that
4139N/Aall decoding functions now require and extra parameter. Most programs
4139N/Acan be modified to work with 2.0 by adding a ``0`` as the second
4139N/Aparameter to all calls of :func:`json_loads()`, :func:`json_loadf()`
4139N/Aand :func:`json_load_file()`.
4139N/A
4139N/A
4139N/ACompatibility
4139N/A=============
4139N/A
4139N/AJansson 2.0 is backwards incompatible with the Jansson 1.x releases.
4139N/AIt is ABI incompatible, i.e. all programs dynamically linking to the
4139N/AJansson library need to be recompiled. It's also API incompatible,
4139N/Ai.e. the source code of programs using Jansson 1.x may need
4139N/Amodifications to make them compile against Jansson 2.0.
4139N/A
4139N/AAll the 2.x releases are guaranteed to be backwards compatible for
4139N/Aboth ABI and API, so no recompilation or source changes are needed
4139N/Awhen upgrading from 2.x to 2.y.
4139N/A
4139N/A
4139N/AList of Incompatible Changes
4139N/A============================
4139N/A
4139N/A**Decoding flags**
4139N/A For future needs, a ``flags`` parameter was added as the second
4139N/A parameter to all decoding functions, i.e. :func:`json_loads()`,
4139N/A :func:`json_loadf()` and :func:`json_load_file()`. All calls to
4139N/A these functions need to be changed by adding a ``0`` as the second
4139N/A argument. For example::
4139N/A
4139N/A /* old code */
4139N/A json_loads(input, &error);
4139N/A
4139N/A /* new code */
4139N/A json_loads(input, 0, &error);
4139N/A
4139N/A
4139N/A**Underlying type of JSON integers**
4139N/A The underlying C type of JSON integers has been changed from
4139N/A :type:`int` to the widest available signed integer type, i.e.
4139N/A :type:`long long` or :type:`long`, depending on whether
4139N/A :type:`long long` is supported on your system or not. This makes
4139N/A the whole 64-bit integer range available on most modern systems.
4139N/A
4139N/A ``jansson.h`` has a typedef :type:`json_int_t` to the underlying
4139N/A integer type. :type:`int` should still be used in most cases when
4139N/A dealing with smallish JSON integers, as the compiler handles
4139N/A implicit type coercion. Only when the full 64-bit range is needed,
4139N/A :type:`json_int_t` should be explicitly used.
4139N/A
4139N/A
4139N/A**Maximum encoder indentation depth**
4139N/A The maximum argument of the ``JSON_INDENT()`` macro has been
4139N/A changed from 255 to 31, to free up bits from the ``flags``
4139N/A parameter of :func:`json_dumps()`, :func:`json_dumpf()` and
4139N/A :func:`json_dump_file()`. If your code uses a bigger indentation
4139N/A than 31, it needs to be changed.
4139N/A
4139N/A
4139N/A**Unsigned integers in API functions**
4139N/A Version 2.0 unifies unsigned integer usage in the API. All uses of
4139N/A :type:`unsigned int` and :type:`unsigned long` have been replaced
4139N/A with :type:`size_t`. This includes flags, container sizes, etc.
4139N/A This should not require source code changes, as both
4139N/A :type:`unsigned int` and :type:`unsigned long` are usually
4139N/A compatible with :type:`size_t`.