|
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>RFC Conformance — 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="Portability" href="portability.html" /> |
|
28 <link rel="prev" title="Tutorial" href="tutorial.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="portability.html" title="Portability" |
|
39 accesskey="N">next</a> |</li> |
|
40 <li class="right" > |
|
41 <a href="tutorial.html" title="Tutorial" |
|
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="rfc-conformance"> |
|
53 <span id="id1"></span><h1>RFC Conformance<a class="headerlink" href="#rfc-conformance" title="Permalink to this headline">¶</a></h1> |
|
54 <p>JSON is specified in <span class="target" id="index-0"></span><a class="rfc reference external" href="http://tools.ietf.org/html/rfc4627.html"><strong>RFC 4627</strong></a>, <em>“The application/json Media Type |
|
55 for JavaScript Object Notation (JSON)”</em>.</p> |
|
56 <div class="section" id="character-encoding"> |
|
57 <h2>Character Encoding<a class="headerlink" href="#character-encoding" title="Permalink to this headline">¶</a></h2> |
|
58 <p>Jansson only supports UTF-8 encoded JSON texts. It does not support or |
|
59 auto-detect any of the other encodings mentioned in the RFC, namely |
|
60 UTF-16LE, UTF-16BE, UTF-32LE or UTF-32BE. Pure ASCII is supported, as |
|
61 it’s a subset of UTF-8.</p> |
|
62 </div> |
|
63 <div class="section" id="strings"> |
|
64 <h2>Strings<a class="headerlink" href="#strings" title="Permalink to this headline">¶</a></h2> |
|
65 <p>JSON strings are mapped to C-style null-terminated character arrays, |
|
66 and UTF-8 encoding is used internally.</p> |
|
67 <p>All Unicode codepoints U+0000 through U+10FFFF are allowed in string |
|
68 values. However, U+0000 is not allowed in object keys because of API |
|
69 restrictions.</p> |
|
70 <p>Unicode normalization or any other transformation is never performed |
|
71 on any strings (string values or object keys). When checking for |
|
72 equivalence of strings or object keys, the comparison is performed |
|
73 byte by byte between the original UTF-8 representations of the |
|
74 strings.</p> |
|
75 </div> |
|
76 <div class="section" id="numbers"> |
|
77 <h2>Numbers<a class="headerlink" href="#numbers" title="Permalink to this headline">¶</a></h2> |
|
78 <div class="section" id="real-vs-integer"> |
|
79 <span id="id2"></span><h3>Real vs. Integer<a class="headerlink" href="#real-vs-integer" title="Permalink to this headline">¶</a></h3> |
|
80 <p>JSON makes no distinction between real and integer numbers; Jansson |
|
81 does. Real numbers are mapped to the <tt class="docutils literal"><span class="pre">double</span></tt> type and integers to |
|
82 the <tt class="docutils literal"><span class="pre">json_int_t</span></tt> type, which is a typedef of <tt class="docutils literal"><span class="pre">long</span> <span class="pre">long</span></tt> or |
|
83 <tt class="docutils literal"><span class="pre">long</span></tt>, depending on whether <tt class="docutils literal"><span class="pre">long</span> <span class="pre">long</span></tt> is supported by your |
|
84 compiler or not.</p> |
|
85 <p>A JSON number is considered to be a real number if its lexical |
|
86 representation includes one of <tt class="docutils literal"><span class="pre">e</span></tt>, <tt class="docutils literal"><span class="pre">E</span></tt>, or <tt class="docutils literal"><span class="pre">.</span></tt>; regardless if |
|
87 its actual numeric value is a true integer (e.g., all of <tt class="docutils literal"><span class="pre">1E6</span></tt>, |
|
88 <tt class="docutils literal"><span class="pre">3.0</span></tt>, <tt class="docutils literal"><span class="pre">400E-2</span></tt>, and <tt class="docutils literal"><span class="pre">3.14E3</span></tt> are mathematical integers, but |
|
89 will be treated as real values). With the <tt class="docutils literal"><span class="pre">JSON_DECODE_INT_AS_REAL</span></tt> |
|
90 decoder flag set all numbers are interpreted as real.</p> |
|
91 <p>All other JSON numbers are considered integers.</p> |
|
92 <p>When encoding to JSON, real values are always represented |
|
93 with a fractional part; e.g., the <tt class="docutils literal"><span class="pre">double</span></tt> value 3.0 will be |
|
94 represented in JSON as <tt class="docutils literal"><span class="pre">3.0</span></tt>, not <tt class="docutils literal"><span class="pre">3</span></tt>.</p> |
|
95 </div> |
|
96 <div class="section" id="overflow-underflow-precision"> |
|
97 <h3>Overflow, Underflow & Precision<a class="headerlink" href="#overflow-underflow-precision" title="Permalink to this headline">¶</a></h3> |
|
98 <p>Real numbers whose absolute values are too small to be represented in |
|
99 a C <tt class="docutils literal"><span class="pre">double</span></tt> will be silently estimated with 0.0. Thus, depending on |
|
100 platform, JSON numbers very close to zero such as 1E-999 may result in |
|
101 0.0.</p> |
|
102 <p>Real numbers whose absolute values are too large to be represented in |
|
103 a C <tt class="docutils literal"><span class="pre">double</span></tt> will result in an overflow error (a JSON decoding |
|
104 error). Thus, depending on platform, JSON numbers like 1E+999 or |
|
105 -1E+999 may result in a parsing error.</p> |
|
106 <p>Likewise, integer numbers whose absolute values are too large to be |
|
107 represented in the <tt class="docutils literal"><span class="pre">json_int_t</span></tt> type (see above) will result in an |
|
108 overflow error (a JSON decoding error). Thus, depending on platform, |
|
109 JSON numbers like 1000000000000000 may result in parsing error.</p> |
|
110 <p>Parsing JSON real numbers may result in a loss of precision. As long |
|
111 as overflow does not occur (i.e. a total loss of precision), the |
|
112 rounded approximate value is silently used. Thus the JSON number |
|
113 1.000000000000000005 may, depending on platform, result in the |
|
114 <tt class="docutils literal"><span class="pre">double</span></tt> value 1.0.</p> |
|
115 </div> |
|
116 <div class="section" id="signed-zeros"> |
|
117 <h3>Signed zeros<a class="headerlink" href="#signed-zeros" title="Permalink to this headline">¶</a></h3> |
|
118 <p>JSON makes no statement about what a number means; however Javascript |
|
119 (ECMAscript) does state that +0.0 and -0.0 must be treated as being |
|
120 distinct values, i.e. -0.0 ≠ 0.0. Jansson relies on the |
|
121 underlying floating point library in the C environment in which it is |
|
122 compiled. Therefore it is platform-dependent whether 0.0 and -0.0 will |
|
123 be distinct values. Most platforms that use the IEEE 754 |
|
124 floating-point standard will support signed zeros.</p> |
|
125 <p>Note that this only applies to floating-point; neither JSON, C, or |
|
126 IEEE support the concept of signed integer zeros.</p> |
|
127 </div> |
|
128 <div class="section" id="types"> |
|
129 <h3>Types<a class="headerlink" href="#types" title="Permalink to this headline">¶</a></h3> |
|
130 <p>No support is provided in Jansson for any C numeric types other than |
|
131 <tt class="docutils literal"><span class="pre">json_int_t</span></tt> and <tt class="docutils literal"><span class="pre">double</span></tt>. This excludes things such as unsigned |
|
132 types, <tt class="docutils literal"><span class="pre">long</span> <span class="pre">double</span></tt>, etc. Obviously, shorter types like <tt class="docutils literal"><span class="pre">short</span></tt>, |
|
133 <tt class="docutils literal"><span class="pre">int</span></tt>, <tt class="docutils literal"><span class="pre">long</span></tt> (if <tt class="docutils literal"><span class="pre">json_int_t</span></tt> is <tt class="docutils literal"><span class="pre">long</span> <span class="pre">long</span></tt>) and <tt class="docutils literal"><span class="pre">float</span></tt> |
|
134 are implicitly handled via the ordinary C type coercion rules (subject |
|
135 to overflow semantics). Also, no support or hooks are provided for any |
|
136 supplemental “bignum” type add-on packages.</p> |
|
137 </div> |
|
138 </div> |
|
139 </div> |
|
140 |
|
141 |
|
142 </div> |
|
143 </div> |
|
144 </div> |
|
145 <div class="sphinxsidebar"> |
|
146 <div class="sphinxsidebarwrapper"> |
|
147 <h3><a href="index.html">Table Of Contents</a></h3> |
|
148 <ul> |
|
149 <li><a class="reference internal" href="#">RFC Conformance</a><ul> |
|
150 <li><a class="reference internal" href="#character-encoding">Character Encoding</a></li> |
|
151 <li><a class="reference internal" href="#strings">Strings</a></li> |
|
152 <li><a class="reference internal" href="#numbers">Numbers</a><ul> |
|
153 <li><a class="reference internal" href="#real-vs-integer">Real vs. Integer</a></li> |
|
154 <li><a class="reference internal" href="#overflow-underflow-precision">Overflow, Underflow & Precision</a></li> |
|
155 <li><a class="reference internal" href="#signed-zeros">Signed zeros</a></li> |
|
156 <li><a class="reference internal" href="#types">Types</a></li> |
|
157 </ul> |
|
158 </li> |
|
159 </ul> |
|
160 </li> |
|
161 </ul> |
|
162 |
|
163 <h4>Previous topic</h4> |
|
164 <p class="topless"><a href="tutorial.html" |
|
165 title="previous chapter">Tutorial</a></p> |
|
166 <h4>Next topic</h4> |
|
167 <p class="topless"><a href="portability.html" |
|
168 title="next chapter">Portability</a></p> |
|
169 <h3>This Page</h3> |
|
170 <ul class="this-page-menu"> |
|
171 <li><a href="_sources/conformance.txt" |
|
172 rel="nofollow">Show Source</a></li> |
|
173 </ul> |
|
174 <div id="searchbox" style="display: none"> |
|
175 <h3>Quick search</h3> |
|
176 <form class="search" action="search.html" method="get"> |
|
177 <input type="text" name="q" /> |
|
178 <input type="submit" value="Go" /> |
|
179 <input type="hidden" name="check_keywords" value="yes" /> |
|
180 <input type="hidden" name="area" value="default" /> |
|
181 </form> |
|
182 <p class="searchtip" style="font-size: 90%"> |
|
183 Enter search terms or a module, class or function name. |
|
184 </p> |
|
185 </div> |
|
186 <script type="text/javascript">$('#searchbox').show(0);</script> |
|
187 </div> |
|
188 </div> |
|
189 <div class="clearer"></div> |
|
190 </div> |
|
191 <div class="related"> |
|
192 <h3>Navigation</h3> |
|
193 <ul> |
|
194 <li class="right" style="margin-right: 10px"> |
|
195 <a href="genindex.html" title="General Index" |
|
196 >index</a></li> |
|
197 <li class="right" > |
|
198 <a href="portability.html" title="Portability" |
|
199 >next</a> |</li> |
|
200 <li class="right" > |
|
201 <a href="tutorial.html" title="Tutorial" |
|
202 >previous</a> |</li> |
|
203 <li><a href="index.html">Jansson 2.7 documentation</a> »</li> |
|
204 </ul> |
|
205 </div> |
|
206 <div class="footer"> |
|
207 © Copyright 2009-2014, Petri Lehtinen. |
|
208 Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2. |
|
209 </div> |
|
210 </body> |
|
211 </html> |