conformance.html revision 4139
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>RFC Conformance &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="Portability" href="portability.html" />
4139N/A <link rel="prev" title="Tutorial" href="tutorial.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="portability.html" title="Portability"
4139N/A accesskey="N">next</a> |</li>
4139N/A <li class="right" >
4139N/A <a href="tutorial.html" title="Tutorial"
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="rfc-conformance">
4139N/A<span id="id1"></span><h1>RFC Conformance<a class="headerlink" href="#rfc-conformance" title="Permalink to this headline">¶</a></h1>
4139N/A<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>&#8220;The application/json Media Type
4139N/Afor JavaScript Object Notation (JSON)&#8221;</em>.</p>
4139N/A<div class="section" id="character-encoding">
4139N/A<h2>Character Encoding<a class="headerlink" href="#character-encoding" title="Permalink to this headline">¶</a></h2>
4139N/A<p>Jansson only supports UTF-8 encoded JSON texts. It does not support or
4139N/Aauto-detect any of the other encodings mentioned in the RFC, namely
4139N/AUTF-16LE, UTF-16BE, UTF-32LE or UTF-32BE. Pure ASCII is supported, as
4139N/Ait&#8217;s a subset of UTF-8.</p>
4139N/A</div>
4139N/A<div class="section" id="strings">
4139N/A<h2>Strings<a class="headerlink" href="#strings" title="Permalink to this headline">¶</a></h2>
4139N/A<p>JSON strings are mapped to C-style null-terminated character arrays,
4139N/Aand UTF-8 encoding is used internally.</p>
4139N/A<p>All Unicode codepoints U+0000 through U+10FFFF are allowed in string
4139N/Avalues. However, U+0000 is not allowed in object keys because of API
4139N/Arestrictions.</p>
4139N/A<p>Unicode normalization or any other transformation is never performed
4139N/Aon any strings (string values or object keys). When checking for
4139N/Aequivalence of strings or object keys, the comparison is performed
4139N/Abyte by byte between the original UTF-8 representations of the
4139N/Astrings.</p>
4139N/A</div>
4139N/A<div class="section" id="numbers">
4139N/A<h2>Numbers<a class="headerlink" href="#numbers" title="Permalink to this headline">¶</a></h2>
4139N/A<div class="section" id="real-vs-integer">
4139N/A<span id="id2"></span><h3>Real vs. Integer<a class="headerlink" href="#real-vs-integer" title="Permalink to this headline">¶</a></h3>
4139N/A<p>JSON makes no distinction between real and integer numbers; Jansson
4139N/Adoes. Real numbers are mapped to the <tt class="docutils literal"><span class="pre">double</span></tt> type and integers to
4139N/Athe <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
4139N/A<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
4139N/Acompiler or not.</p>
4139N/A<p>A JSON number is considered to be a real number if its lexical
4139N/Arepresentation 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
4139N/Aits actual numeric value is a true integer (e.g., all of <tt class="docutils literal"><span class="pre">1E6</span></tt>,
4139N/A<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
4139N/Awill be treated as real values). With the <tt class="docutils literal"><span class="pre">JSON_DECODE_INT_AS_REAL</span></tt>
4139N/Adecoder flag set all numbers are interpreted as real.</p>
4139N/A<p>All other JSON numbers are considered integers.</p>
4139N/A<p>When encoding to JSON, real values are always represented
4139N/Awith a fractional part; e.g., the <tt class="docutils literal"><span class="pre">double</span></tt> value 3.0 will be
4139N/Arepresented 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>
4139N/A</div>
4139N/A<div class="section" id="overflow-underflow-precision">
4139N/A<h3>Overflow, Underflow &amp; Precision<a class="headerlink" href="#overflow-underflow-precision" title="Permalink to this headline">¶</a></h3>
4139N/A<p>Real numbers whose absolute values are too small to be represented in
4139N/Aa C <tt class="docutils literal"><span class="pre">double</span></tt> will be silently estimated with 0.0. Thus, depending on
4139N/Aplatform, JSON numbers very close to zero such as 1E-999 may result in
4139N/A0.0.</p>
4139N/A<p>Real numbers whose absolute values are too large to be represented in
4139N/Aa C <tt class="docutils literal"><span class="pre">double</span></tt> will result in an overflow error (a JSON decoding
4139N/Aerror). Thus, depending on platform, JSON numbers like 1E+999 or
4139N/A-1E+999 may result in a parsing error.</p>
4139N/A<p>Likewise, integer numbers whose absolute values are too large to be
4139N/Arepresented in the <tt class="docutils literal"><span class="pre">json_int_t</span></tt> type (see above) will result in an
4139N/Aoverflow error (a JSON decoding error). Thus, depending on platform,
4139N/AJSON numbers like 1000000000000000 may result in parsing error.</p>
4139N/A<p>Parsing JSON real numbers may result in a loss of precision. As long
4139N/Aas overflow does not occur (i.e. a total loss of precision), the
4139N/Arounded approximate value is silently used. Thus the JSON number
4139N/A1.000000000000000005 may, depending on platform, result in the
4139N/A<tt class="docutils literal"><span class="pre">double</span></tt> value 1.0.</p>
4139N/A</div>
4139N/A<div class="section" id="signed-zeros">
4139N/A<h3>Signed zeros<a class="headerlink" href="#signed-zeros" title="Permalink to this headline">¶</a></h3>
4139N/A<p>JSON makes no statement about what a number means; however Javascript
4139N/A(ECMAscript) does state that +0.0 and -0.0 must be treated as being
4139N/Adistinct values, i.e. -0.0 ≠ 0.0. Jansson relies on the
4139N/Aunderlying floating point library in the C environment in which it is
4139N/Acompiled. Therefore it is platform-dependent whether 0.0 and -0.0 will
4139N/Abe distinct values. Most platforms that use the IEEE 754
4139N/Afloating-point standard will support signed zeros.</p>
4139N/A<p>Note that this only applies to floating-point; neither JSON, C, or
4139N/AIEEE support the concept of signed integer zeros.</p>
4139N/A</div>
4139N/A<div class="section" id="types">
4139N/A<h3>Types<a class="headerlink" href="#types" title="Permalink to this headline">¶</a></h3>
4139N/A<p>No support is provided in Jansson for any C numeric types other than
4139N/A<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
4139N/Atypes, <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>,
4139N/A<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>
4139N/Aare implicitly handled via the ordinary C type coercion rules (subject
4139N/Ato overflow semantics). Also, no support or hooks are provided for any
4139N/Asupplemental &#8220;bignum&#8221; type add-on packages.</p>
4139N/A</div>
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="#">RFC Conformance</a><ul>
4139N/A<li><a class="reference internal" href="#character-encoding">Character Encoding</a></li>
4139N/A<li><a class="reference internal" href="#strings">Strings</a></li>
4139N/A<li><a class="reference internal" href="#numbers">Numbers</a><ul>
4139N/A<li><a class="reference internal" href="#real-vs-integer">Real vs. Integer</a></li>
4139N/A<li><a class="reference internal" href="#overflow-underflow-precision">Overflow, Underflow &amp; Precision</a></li>
4139N/A<li><a class="reference internal" href="#signed-zeros">Signed zeros</a></li>
4139N/A<li><a class="reference internal" href="#types">Types</a></li>
4139N/A</ul>
4139N/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="tutorial.html"
4139N/A title="previous chapter">Tutorial</a></p>
4139N/A <h4>Next topic</h4>
4139N/A <p class="topless"><a href="portability.html"
4139N/A title="next chapter">Portability</a></p>
4139N/A <h3>This Page</h3>
4139N/A <ul class="this-page-menu">
4139N/A <li><a href="_sources/conformance.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="portability.html" title="Portability"
4139N/A >next</a> |</li>
4139N/A <li class="right" >
4139N/A <a href="tutorial.html" title="Tutorial"
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>