4139N/A<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4139N/A "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4139N/A
4139N/A
4139N/A<html xmlns="http://www.w3.org/1999/xhtml">
4139N/A <head>
4139N/A <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4139N/A
4139N/A <title>Upgrading from 1.x &mdash; Jansson 2.7 documentation</title>
4139N/A
4139N/A <link rel="stylesheet" href="_static/default.css" type="text/css" />
4139N/A <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
4139N/A
4139N/A <script type="text/javascript">
4139N/A var DOCUMENTATION_OPTIONS = {
4139N/A URL_ROOT: './',
4139N/A VERSION: '2.7',
4139N/A COLLAPSE_INDEX: false,
4139N/A FILE_SUFFIX: '.html',
4139N/A HAS_SOURCE: true
4139N/A };
4139N/A </script>
4139N/A <script type="text/javascript" src="_static/jquery.js"></script>
4139N/A <script type="text/javascript" src="_static/underscore.js"></script>
4139N/A <script type="text/javascript" src="_static/doctools.js"></script>
4139N/A <link rel="top" title="Jansson 2.7 documentation" href="index.html" />
4139N/A <link rel="next" title="Tutorial" href="tutorial.html" />
4139N/A <link rel="prev" title="Getting Started" href="gettingstarted.html" />
4139N/A </head>
4139N/A <body>
4139N/A <div class="related">
4139N/A <h3>Navigation</h3>
4139N/A <ul>
4139N/A <li class="right" style="margin-right: 10px">
4139N/A <a href="genindex.html" title="General Index"
4139N/A accesskey="I">index</a></li>
4139N/A <li class="right" >
4139N/A <a href="tutorial.html" title="Tutorial"
4139N/A accesskey="N">next</a> |</li>
4139N/A <li class="right" >
4139N/A <a href="gettingstarted.html" title="Getting Started"
4139N/A accesskey="P">previous</a> |</li>
4139N/A <li><a href="index.html">Jansson 2.7 documentation</a> &raquo;</li>
4139N/A </ul>
4139N/A </div>
4139N/A
4139N/A <div class="document">
4139N/A <div class="documentwrapper">
4139N/A <div class="bodywrapper">
4139N/A <div class="body">
4139N/A
4139N/A <div class="section" id="upgrading-from-1-x">
4139N/A<h1>Upgrading from 1.x<a class="headerlink" href="#upgrading-from-1-x" title="Permalink to this headline">¶</a></h1>
4139N/A<p>This chapter lists the backwards incompatible changes introduced in
4139N/AJansson 2.0, and the steps that are needed for upgrading your code.</p>
4139N/A<p><strong>The incompatibilities are not dramatic.</strong> 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 <tt class="docutils literal"><span class="pre">0</span></tt> as the second
4139N/Aparameter to all calls of <a class="reference internal" href="apiref.html#c.json_loads" title="json_loads"><tt class="xref c c-func docutils literal"><span class="pre">json_loads()</span></tt></a>, <a class="reference internal" href="apiref.html#c.json_loadf" title="json_loadf"><tt class="xref c c-func docutils literal"><span class="pre">json_loadf()</span></tt></a>
4139N/Aand <a class="reference internal" href="apiref.html#c.json_load_file" title="json_load_file"><tt class="xref c c-func docutils literal"><span class="pre">json_load_file()</span></tt></a>.</p>
4139N/A<div class="section" id="compatibility">
4139N/A<h2>Compatibility<a class="headerlink" href="#compatibility" title="Permalink to this headline">¶</a></h2>
4139N/A<p>Jansson 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&#8217;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.</p>
4139N/A<p>All 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.</p>
4139N/A</div>
4139N/A<div class="section" id="list-of-incompatible-changes">
4139N/A<h2>List of Incompatible Changes<a class="headerlink" href="#list-of-incompatible-changes" title="Permalink to this headline">¶</a></h2>
4139N/A<dl class="docutils">
4139N/A<dt><strong>Decoding flags</strong></dt>
4139N/A<dd><p class="first">For future needs, a <tt class="docutils literal"><span class="pre">flags</span></tt> parameter was added as the second
4139N/Aparameter to all decoding functions, i.e. <a class="reference internal" href="apiref.html#c.json_loads" title="json_loads"><tt class="xref c c-func docutils literal"><span class="pre">json_loads()</span></tt></a>,
4139N/A<a class="reference internal" href="apiref.html#c.json_loadf" title="json_loadf"><tt class="xref c c-func docutils literal"><span class="pre">json_loadf()</span></tt></a> and <a class="reference internal" href="apiref.html#c.json_load_file" title="json_load_file"><tt class="xref c c-func docutils literal"><span class="pre">json_load_file()</span></tt></a>. All calls to
4139N/Athese functions need to be changed by adding a <tt class="docutils literal"><span class="pre">0</span></tt> as the second
4139N/Aargument. For example:</p>
4139N/A<div class="last highlight-c"><div class="highlight"><pre><span class="cm">/* old code */</span>
4139N/A<span class="n">json_loads</span><span class="p">(</span><span class="n">input</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">error</span><span class="p">);</span>
4139N/A
4139N/A<span class="cm">/* new code */</span>
4139N/A<span class="n">json_loads</span><span class="p">(</span><span class="n">input</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">error</span><span class="p">);</span>
4139N/A</pre></div>
4139N/A</div>
4139N/A</dd>
4139N/A<dt><strong>Underlying type of JSON integers</strong></dt>
4139N/A<dd><p class="first">The underlying C type of JSON integers has been changed from
4139N/A<tt class="xref c c-type docutils literal"><span class="pre">int</span></tt> to the widest available signed integer type, i.e.
4139N/A<tt class="xref c c-type docutils literal"><span class="pre">long</span> <span class="pre">long</span></tt> or <tt class="xref c c-type docutils literal"><span class="pre">long</span></tt>, depending on whether
4139N/A<tt class="xref c c-type docutils literal"><span class="pre">long</span> <span class="pre">long</span></tt> is supported on your system or not. This makes
4139N/Athe whole 64-bit integer range available on most modern systems.</p>
4139N/A<p class="last"><tt class="docutils literal"><span class="pre">jansson.h</span></tt> has a typedef <a class="reference internal" href="apiref.html#c.json_int_t" title="json_int_t"><tt class="xref c c-type docutils literal"><span class="pre">json_int_t</span></tt></a> to the underlying
4139N/Ainteger type. <tt class="xref c c-type docutils literal"><span class="pre">int</span></tt> should still be used in most cases when
4139N/Adealing with smallish JSON integers, as the compiler handles
4139N/Aimplicit type coercion. Only when the full 64-bit range is needed,
4139N/A<a class="reference internal" href="apiref.html#c.json_int_t" title="json_int_t"><tt class="xref c c-type docutils literal"><span class="pre">json_int_t</span></tt></a> should be explicitly used.</p>
4139N/A</dd>
4139N/A<dt><strong>Maximum encoder indentation depth</strong></dt>
4139N/A<dd>The maximum argument of the <tt class="docutils literal"><span class="pre">JSON_INDENT()</span></tt> macro has been
4139N/Achanged from 255 to 31, to free up bits from the <tt class="docutils literal"><span class="pre">flags</span></tt>
4139N/Aparameter of <a class="reference internal" href="apiref.html#c.json_dumps" title="json_dumps"><tt class="xref c c-func docutils literal"><span class="pre">json_dumps()</span></tt></a>, <a class="reference internal" href="apiref.html#c.json_dumpf" title="json_dumpf"><tt class="xref c c-func docutils literal"><span class="pre">json_dumpf()</span></tt></a> and
4139N/A<a class="reference internal" href="apiref.html#c.json_dump_file" title="json_dump_file"><tt class="xref c c-func docutils literal"><span class="pre">json_dump_file()</span></tt></a>. If your code uses a bigger indentation
4139N/Athan 31, it needs to be changed.</dd>
4139N/A<dt><strong>Unsigned integers in API functions</strong></dt>
4139N/A<dd>Version 2.0 unifies unsigned integer usage in the API. All uses of
4139N/A<tt class="xref c c-type docutils literal"><span class="pre">unsigned</span> <span class="pre">int</span></tt> and <tt class="xref c c-type docutils literal"><span class="pre">unsigned</span> <span class="pre">long</span></tt> have been replaced
4139N/Awith <tt class="xref c c-type docutils literal"><span class="pre">size_t</span></tt>. This includes flags, container sizes, etc.
4139N/AThis should not require source code changes, as both
4139N/A<tt class="xref c c-type docutils literal"><span class="pre">unsigned</span> <span class="pre">int</span></tt> and <tt class="xref c c-type docutils literal"><span class="pre">unsigned</span> <span class="pre">long</span></tt> are usually
4139N/Acompatible with <tt class="xref c c-type docutils literal"><span class="pre">size_t</span></tt>.</dd>
4139N/A</dl>
4139N/A</div>
4139N/A</div>
4139N/A
4139N/A
4139N/A </div>
4139N/A </div>
4139N/A </div>
4139N/A <div class="sphinxsidebar">
4139N/A <div class="sphinxsidebarwrapper">
4139N/A <h3><a href="index.html">Table Of Contents</a></h3>
4139N/A <ul>
4139N/A<li><a class="reference internal" href="#">Upgrading from 1.x</a><ul>
4139N/A<li><a class="reference internal" href="#compatibility">Compatibility</a></li>
4139N/A<li><a class="reference internal" href="#list-of-incompatible-changes">List of Incompatible Changes</a></li>
4139N/A</ul>
4139N/A</li>
4139N/A</ul>
4139N/A
4139N/A <h4>Previous topic</h4>
4139N/A <p class="topless"><a href="gettingstarted.html"
4139N/A title="previous chapter">Getting Started</a></p>
4139N/A <h4>Next topic</h4>
4139N/A <p class="topless"><a href="tutorial.html"
4139N/A title="next chapter">Tutorial</a></p>
4139N/A <h3>This Page</h3>
4139N/A <ul class="this-page-menu">
4139N/A <li><a href="_sources/upgrading.txt"
4139N/A rel="nofollow">Show Source</a></li>
4139N/A </ul>
4139N/A<div id="searchbox" style="display: none">
4139N/A <h3>Quick search</h3>
4139N/A <form class="search" action="search.html" method="get">
4139N/A <input type="text" name="q" />
4139N/A <input type="submit" value="Go" />
4139N/A <input type="hidden" name="check_keywords" value="yes" />
4139N/A <input type="hidden" name="area" value="default" />
4139N/A </form>
4139N/A <p class="searchtip" style="font-size: 90%">
4139N/A Enter search terms or a module, class or function name.
4139N/A </p>
4139N/A</div>
4139N/A<script type="text/javascript">$('#searchbox').show(0);</script>
4139N/A </div>
4139N/A </div>
4139N/A <div class="clearer"></div>
4139N/A </div>
4139N/A <div class="related">
4139N/A <h3>Navigation</h3>
4139N/A <ul>
4139N/A <li class="right" style="margin-right: 10px">
4139N/A <a href="genindex.html" title="General Index"
4139N/A >index</a></li>
4139N/A <li class="right" >
4139N/A <a href="tutorial.html" title="Tutorial"
4139N/A >next</a> |</li>
4139N/A <li class="right" >
4139N/A <a href="gettingstarted.html" title="Getting Started"
4139N/A >previous</a> |</li>
4139N/A <li><a href="index.html">Jansson 2.7 documentation</a> &raquo;</li>
4139N/A </ul>
4139N/A </div>
4139N/A <div class="footer">
4139N/A &copy; Copyright 2009-2014, Petri Lehtinen.
4139N/A Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
4139N/A </div>
4139N/A </body>
4139N/A</html>