2190
|
1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
2 |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
3 |
|
|
4 |
|
|
5 |
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
6 |
<head>
|
|
7 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
8 |
|
|
9 |
<title>Upgrading from 1.x — Jansson 2.7 documentation</title>
|
|
10 |
|
|
11 |
<link rel="stylesheet" href="_static/default.css" type="text/css" />
|
|
12 |
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
|
13 |
|
|
14 |
<script type="text/javascript">
|
|
15 |
var DOCUMENTATION_OPTIONS = {
|
|
16 |
URL_ROOT: './',
|
|
17 |
VERSION: '2.7',
|
|
18 |
COLLAPSE_INDEX: false,
|
|
19 |
FILE_SUFFIX: '.html',
|
|
20 |
HAS_SOURCE: true
|
|
21 |
};
|
|
22 |
</script>
|
|
23 |
<script type="text/javascript" src="_static/jquery.js"></script>
|
|
24 |
<script type="text/javascript" src="_static/underscore.js"></script>
|
|
25 |
<script type="text/javascript" src="_static/doctools.js"></script>
|
|
26 |
<link rel="top" title="Jansson 2.7 documentation" href="index.html" />
|
|
27 |
<link rel="next" title="Tutorial" href="tutorial.html" />
|
|
28 |
<link rel="prev" title="Getting Started" href="gettingstarted.html" />
|
|
29 |
</head>
|
|
30 |
<body>
|
|
31 |
<div class="related">
|
|
32 |
<h3>Navigation</h3>
|
|
33 |
<ul>
|
|
34 |
<li class="right" style="margin-right: 10px">
|
|
35 |
<a href="genindex.html" title="General Index"
|
|
36 |
accesskey="I">index</a></li>
|
|
37 |
<li class="right" >
|
|
38 |
<a href="tutorial.html" title="Tutorial"
|
|
39 |
accesskey="N">next</a> |</li>
|
|
40 |
<li class="right" >
|
|
41 |
<a href="gettingstarted.html" title="Getting Started"
|
|
42 |
accesskey="P">previous</a> |</li>
|
|
43 |
<li><a href="index.html">Jansson 2.7 documentation</a> »</li>
|
|
44 |
</ul>
|
|
45 |
</div>
|
|
46 |
|
|
47 |
<div class="document">
|
|
48 |
<div class="documentwrapper">
|
|
49 |
<div class="bodywrapper">
|
|
50 |
<div class="body">
|
|
51 |
|
|
52 |
<div class="section" id="upgrading-from-1-x">
|
|
53 |
<h1>Upgrading from 1.x<a class="headerlink" href="#upgrading-from-1-x" title="Permalink to this headline">¶</a></h1>
|
|
54 |
<p>This chapter lists the backwards incompatible changes introduced in
|
|
55 |
Jansson 2.0, and the steps that are needed for upgrading your code.</p>
|
|
56 |
<p><strong>The incompatibilities are not dramatic.</strong> The biggest change is that
|
|
57 |
all decoding functions now require and extra parameter. Most programs
|
|
58 |
can be modified to work with 2.0 by adding a <tt class="docutils literal"><span class="pre">0</span></tt> as the second
|
|
59 |
parameter 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>
|
|
60 |
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>.</p>
|
|
61 |
<div class="section" id="compatibility">
|
|
62 |
<h2>Compatibility<a class="headerlink" href="#compatibility" title="Permalink to this headline">¶</a></h2>
|
|
63 |
<p>Jansson 2.0 is backwards incompatible with the Jansson 1.x releases.
|
|
64 |
It is ABI incompatible, i.e. all programs dynamically linking to the
|
|
65 |
Jansson library need to be recompiled. It’s also API incompatible,
|
|
66 |
i.e. the source code of programs using Jansson 1.x may need
|
|
67 |
modifications to make them compile against Jansson 2.0.</p>
|
|
68 |
<p>All the 2.x releases are guaranteed to be backwards compatible for
|
|
69 |
both ABI and API, so no recompilation or source changes are needed
|
|
70 |
when upgrading from 2.x to 2.y.</p>
|
|
71 |
</div>
|
|
72 |
<div class="section" id="list-of-incompatible-changes">
|
|
73 |
<h2>List of Incompatible Changes<a class="headerlink" href="#list-of-incompatible-changes" title="Permalink to this headline">¶</a></h2>
|
|
74 |
<dl class="docutils">
|
|
75 |
<dt><strong>Decoding flags</strong></dt>
|
|
76 |
<dd><p class="first">For future needs, a <tt class="docutils literal"><span class="pre">flags</span></tt> parameter was added as the second
|
|
77 |
parameter 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>,
|
|
78 |
<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
|
|
79 |
these functions need to be changed by adding a <tt class="docutils literal"><span class="pre">0</span></tt> as the second
|
|
80 |
argument. For example:</p>
|
|
81 |
<div class="last highlight-c"><div class="highlight"><pre><span class="cm">/* old code */</span>
|
|
82 |
<span class="n">json_loads</span><span class="p">(</span><span class="n">input</span><span class="p">,</span> <span class="o">&</span><span class="n">error</span><span class="p">);</span>
|
|
83 |
|
|
84 |
<span class="cm">/* new code */</span>
|
|
85 |
<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">&</span><span class="n">error</span><span class="p">);</span>
|
|
86 |
</pre></div>
|
|
87 |
</div>
|
|
88 |
</dd>
|
|
89 |
<dt><strong>Underlying type of JSON integers</strong></dt>
|
|
90 |
<dd><p class="first">The underlying C type of JSON integers has been changed from
|
|
91 |
<tt class="xref c c-type docutils literal"><span class="pre">int</span></tt> to the widest available signed integer type, i.e.
|
|
92 |
<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
|
|
93 |
<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
|
|
94 |
the whole 64-bit integer range available on most modern systems.</p>
|
|
95 |
<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
|
|
96 |
integer type. <tt class="xref c c-type docutils literal"><span class="pre">int</span></tt> should still be used in most cases when
|
|
97 |
dealing with smallish JSON integers, as the compiler handles
|
|
98 |
implicit type coercion. Only when the full 64-bit range is needed,
|
|
99 |
<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>
|
|
100 |
</dd>
|
|
101 |
<dt><strong>Maximum encoder indentation depth</strong></dt>
|
|
102 |
<dd>The maximum argument of the <tt class="docutils literal"><span class="pre">JSON_INDENT()</span></tt> macro has been
|
|
103 |
changed from 255 to 31, to free up bits from the <tt class="docutils literal"><span class="pre">flags</span></tt>
|
|
104 |
parameter 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
|
|
105 |
<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
|
|
106 |
than 31, it needs to be changed.</dd>
|
|
107 |
<dt><strong>Unsigned integers in API functions</strong></dt>
|
|
108 |
<dd>Version 2.0 unifies unsigned integer usage in the API. All uses of
|
|
109 |
<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
|
|
110 |
with <tt class="xref c c-type docutils literal"><span class="pre">size_t</span></tt>. This includes flags, container sizes, etc.
|
|
111 |
This should not require source code changes, as both
|
|
112 |
<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
|
|
113 |
compatible with <tt class="xref c c-type docutils literal"><span class="pre">size_t</span></tt>.</dd>
|
|
114 |
</dl>
|
|
115 |
</div>
|
|
116 |
</div>
|
|
117 |
|
|
118 |
|
|
119 |
</div>
|
|
120 |
</div>
|
|
121 |
</div>
|
|
122 |
<div class="sphinxsidebar">
|
|
123 |
<div class="sphinxsidebarwrapper">
|
|
124 |
<h3><a href="index.html">Table Of Contents</a></h3>
|
|
125 |
<ul>
|
|
126 |
<li><a class="reference internal" href="#">Upgrading from 1.x</a><ul>
|
|
127 |
<li><a class="reference internal" href="#compatibility">Compatibility</a></li>
|
|
128 |
<li><a class="reference internal" href="#list-of-incompatible-changes">List of Incompatible Changes</a></li>
|
|
129 |
</ul>
|
|
130 |
</li>
|
|
131 |
</ul>
|
|
132 |
|
|
133 |
<h4>Previous topic</h4>
|
|
134 |
<p class="topless"><a href="gettingstarted.html"
|
|
135 |
title="previous chapter">Getting Started</a></p>
|
|
136 |
<h4>Next topic</h4>
|
|
137 |
<p class="topless"><a href="tutorial.html"
|
|
138 |
title="next chapter">Tutorial</a></p>
|
|
139 |
<h3>This Page</h3>
|
|
140 |
<ul class="this-page-menu">
|
|
141 |
<li><a href="_sources/upgrading.txt"
|
|
142 |
rel="nofollow">Show Source</a></li>
|
|
143 |
</ul>
|
|
144 |
<div id="searchbox" style="display: none">
|
|
145 |
<h3>Quick search</h3>
|
|
146 |
<form class="search" action="search.html" method="get">
|
|
147 |
<input type="text" name="q" />
|
|
148 |
<input type="submit" value="Go" />
|
|
149 |
<input type="hidden" name="check_keywords" value="yes" />
|
|
150 |
<input type="hidden" name="area" value="default" />
|
|
151 |
</form>
|
|
152 |
<p class="searchtip" style="font-size: 90%">
|
|
153 |
Enter search terms or a module, class or function name.
|
|
154 |
</p>
|
|
155 |
</div>
|
|
156 |
<script type="text/javascript">$('#searchbox').show(0);</script>
|
|
157 |
</div>
|
|
158 |
</div>
|
|
159 |
<div class="clearer"></div>
|
|
160 |
</div>
|
|
161 |
<div class="related">
|
|
162 |
<h3>Navigation</h3>
|
|
163 |
<ul>
|
|
164 |
<li class="right" style="margin-right: 10px">
|
|
165 |
<a href="genindex.html" title="General Index"
|
|
166 |
>index</a></li>
|
|
167 |
<li class="right" >
|
|
168 |
<a href="tutorial.html" title="Tutorial"
|
|
169 |
>next</a> |</li>
|
|
170 |
<li class="right" >
|
|
171 |
<a href="gettingstarted.html" title="Getting Started"
|
|
172 |
>previous</a> |</li>
|
|
173 |
<li><a href="index.html">Jansson 2.7 documentation</a> »</li>
|
|
174 |
</ul>
|
|
175 |
</div>
|
|
176 |
<div class="footer">
|
|
177 |
© Copyright 2009-2014, Petri Lehtinen.
|
|
178 |
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
|
|
179 |
</div>
|
|
180 |
</body>
|
|
181 |
</html> |