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