| <!-- HTML header for doxygen 1.8.7--> |
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <head> |
| <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> |
| <meta http-equiv="X-UA-Compatible" content="IE=9"/> |
| <meta name="generator" content="Doxygen 1.8.16"/> |
| <title>RapidJSON: Features</title> |
| <link href="tabs.css" rel="stylesheet" type="text/css"/> |
| <script type="text/javascript" src="jquery.js"></script> |
| <script type="text/javascript" src="dynsections.js"></script> |
| <link href="navtree.css" rel="stylesheet" type="text/css"/> |
| <script type="text/javascript" src="resize.js"></script> |
| <script type="text/javascript" src="navtreedata.js"></script> |
| <script type="text/javascript" src="navtree.js"></script> |
| <script type="text/javascript"> |
| /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ |
| $(document).ready(initResizable); |
| /* @license-end */</script> |
| <link href="search/search.css" rel="stylesheet" type="text/css"/> |
| <script type="text/javascript" src="search/searchdata.js"></script> |
| <script type="text/javascript" src="search/search.js"></script> |
| <script type="text/javascript"> |
| /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ |
| $(document).ready(function() { init_search(); }); |
| /* @license-end */ |
| </script> |
| <link href="doxygen.css" rel="stylesheet" type="text/css" /> |
| <link href="doxygenextra.css" rel="stylesheet" type="text/css"/> |
| </head> |
| <body> |
| <div id="top"><!-- do not remove this div, it is closed by doxygen! --> |
| <div id="topbanner"><a href="https://github.com/Tencent/rapidjson" title="RapidJSON GitHub"><i class="githublogo"></i></a></div> |
| <div id="MSearchBox" class="MSearchBoxInactive"> |
| <span class="left"> |
| <img id="MSearchSelect" src="search/mag_sel.png" |
| onmouseover="return searchBox.OnSearchSelectShow()" |
| onmouseout="return searchBox.OnSearchSelectHide()" |
| alt=""/> |
| <input type="text" id="MSearchField" value="Search" accesskey="S" |
| onfocus="searchBox.OnSearchFieldFocus(true)" |
| onblur="searchBox.OnSearchFieldFocus(false)" |
| onkeyup="searchBox.OnSearchFieldChange(event)"/> |
| </span><span class="right"> |
| <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a> |
| </span> |
| </div> |
| <!-- end header part --> |
| <!-- Generated by Doxygen 1.8.16 --> |
| <script type="text/javascript"> |
| /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ |
| var searchBox = new SearchBox("searchBox", "search",false,'Search'); |
| /* @license-end */ |
| </script> |
| </div><!-- top --> |
| <div id="side-nav" class="ui-resizable side-nav-resizable"> |
| <div id="nav-tree"> |
| <div id="nav-tree-contents"> |
| <div id="nav-sync" class="sync"></div> |
| </div> |
| </div> |
| <div id="splitbar" style="-moz-user-select:none;" |
| class="ui-resizable-handle"> |
| </div> |
| </div> |
| <script type="text/javascript"> |
| /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ |
| $(document).ready(function(){initNavTree('md_doc_features.html','');}); |
| /* @license-end */ |
| </script> |
| <div id="doc-content"> |
| <!-- window showing the filter options --> |
| <div id="MSearchSelectWindow" |
| onmouseover="return searchBox.OnSearchSelectShow()" |
| onmouseout="return searchBox.OnSearchSelectHide()" |
| onkeydown="return searchBox.OnSearchSelectKey(event)"> |
| </div> |
| |
| <!-- iframe showing the search results (closed by default) --> |
| <div id="MSearchResultsWindow"> |
| <iframe src="javascript:void(0)" frameborder="0" |
| name="MSearchResults" id="MSearchResults"> |
| </iframe> |
| </div> |
| |
| <div class="PageDoc"><div class="header"> |
| <div class="headertitle"> |
| <div class="title">Features </div> </div> |
| </div><!--header--> |
| <div class="contents"> |
| <div class="textblock"><h1><a class="anchor" id="autotoc_md35"></a> |
| General</h1> |
| <ul> |
| <li>Cross-platform<ul> |
| <li>Compilers: Visual Studio, gcc, clang, etc.</li> |
| <li>Architectures: x86, x64, ARM, etc.</li> |
| <li>Operating systems: Windows, Mac OS X, Linux, iOS, Android, etc.</li> |
| </ul> |
| </li> |
| <li>Easy installation<ul> |
| <li>Header files only library. Just copy the headers to your project.</li> |
| </ul> |
| </li> |
| <li>Self-contained, minimal dependences<ul> |
| <li>No STL, BOOST, etc.</li> |
| <li>Only included <code><cstdio></code>, <code><cstdlib></code>, <code><cstring></code>, <code><inttypes.h></code>, <code><new></code>, <code><stdint.h></code>.</li> |
| </ul> |
| </li> |
| <li>Without C++ exception, RTTI</li> |
| <li>High performance<ul> |
| <li>Use template and inline functions to reduce function call overheads.</li> |
| <li>Internal optimized Grisu2 and floating point parsing implementations.</li> |
| <li>Optional SSE2/SSE4.2 support.</li> |
| </ul> |
| </li> |
| </ul> |
| <h1><a class="anchor" id="autotoc_md36"></a> |
| Standard compliance</h1> |
| <ul> |
| <li>RapidJSON should be fully RFC4627/ECMA-404 compliance.</li> |
| <li>Support JSON Pointer (RFC6901).</li> |
| <li>Support JSON Schema Draft v4.</li> |
| <li>Support Unicode surrogate.</li> |
| <li>Support null character (<code>"\u0000"</code>)<ul> |
| <li>For example, <code>["Hello\u0000World"]</code> can be parsed and handled gracefully. There is API for getting/setting lengths of string.</li> |
| </ul> |
| </li> |
| <li>Support optional relaxed syntax.<ul> |
| <li>Single line (<code>// ...</code>) and multiple line (<code>/* ... */</code>) comments (<code>kParseCommentsFlag</code>).</li> |
| <li>Trailing commas at the end of objects and arrays (<code>kParseTrailingCommasFlag</code>).</li> |
| <li><code>NaN</code>, <code>Inf</code>, <code>Infinity</code>, <code>-Inf</code> and <code>-Infinity</code> as <code>double</code> values (<code>kParseNanAndInfFlag</code>)</li> |
| </ul> |
| </li> |
| <li><a href="http://github.com/Tencent/rapidjson/blob/master/doc/npm.md">NPM compliant</a>.</li> |
| </ul> |
| <h1><a class="anchor" id="autotoc_md37"></a> |
| Unicode</h1> |
| <ul> |
| <li>Support UTF-8, UTF-16, UTF-32 encodings, including little endian and big endian.<ul> |
| <li>These encodings are used in input/output streams and in-memory representation.</li> |
| </ul> |
| </li> |
| <li>Support automatic detection of encodings in input stream.</li> |
| <li>Support transcoding between encodings internally.<ul> |
| <li>For example, you can read a UTF-8 file and let RapidJSON transcode the JSON strings into UTF-16 in the DOM.</li> |
| </ul> |
| </li> |
| <li>Support encoding validation internally.<ul> |
| <li>For example, you can read a UTF-8 file, and let RapidJSON check whether all JSON strings are valid UTF-8 byte sequence.</li> |
| </ul> |
| </li> |
| <li>Support custom character types.<ul> |
| <li>By default the character types are <code>char</code> for UTF8, <code>wchar_t</code> for UTF16, <code>uint32_t</code> for UTF32.</li> |
| </ul> |
| </li> |
| <li>Support custom encodings.</li> |
| </ul> |
| <h1><a class="anchor" id="autotoc_md38"></a> |
| API styles</h1> |
| <ul> |
| <li>SAX (Simple API for XML) style API<ul> |
| <li>Similar to <a href="http://en.wikipedia.org/wiki/Simple_API_for_XML">SAX</a>, RapidJSON provides a event sequential access parser API (<code><a class="el" href="classrapidjson_1_1_generic_reader.html" title="SAX-style JSON parser. Use Reader for UTF8 encoding and default allocator.">rapidjson::GenericReader</a></code>). It also provides a generator API (<code><a class="el" href="classrapidjson_1_1_writer.html" title="JSON writer.">rapidjson::Writer</a></code>) which consumes the same set of events.</li> |
| </ul> |
| </li> |
| <li>DOM (Document Object Model) style API<ul> |
| <li>Similar to <a href="http://en.wikipedia.org/wiki/Document_Object_Model">DOM</a> for HTML/XML, RapidJSON can parse JSON into a DOM representation (<code><a class="el" href="classrapidjson_1_1_generic_document.html" title="A document for parsing JSON text as DOM.">rapidjson::GenericDocument</a></code>), for easy manipulation, and finally stringify back to JSON if needed.</li> |
| <li>The DOM style API (<code><a class="el" href="classrapidjson_1_1_generic_document.html" title="A document for parsing JSON text as DOM.">rapidjson::GenericDocument</a></code>) is actually implemented with SAX style API (<code><a class="el" href="classrapidjson_1_1_generic_reader.html" title="SAX-style JSON parser. Use Reader for UTF8 encoding and default allocator.">rapidjson::GenericReader</a></code>). SAX is faster but sometimes DOM is easier. Users can pick their choices according to scenarios.</li> |
| </ul> |
| </li> |
| </ul> |
| <h1><a class="anchor" id="autotoc_md39"></a> |
| Parsing</h1> |
| <ul> |
| <li>Recursive (default) and iterative parser<ul> |
| <li>Recursive parser is faster but prone to stack overflow in extreme cases.</li> |
| <li>Iterative parser use custom stack to keep parsing state.</li> |
| </ul> |
| </li> |
| <li>Support <em>in situ</em> parsing.<ul> |
| <li>Parse JSON string values in-place at the source JSON, and then the DOM points to addresses of those strings.</li> |
| <li>Faster than convention parsing: no allocation for strings, no copy (if string does not contain escapes), cache-friendly.</li> |
| </ul> |
| </li> |
| <li>Support 32-bit/64-bit signed/unsigned integer and <code>double</code> for JSON number type.</li> |
| <li>Support parsing multiple JSONs in input stream (<code>kParseStopWhenDoneFlag</code>).</li> |
| <li>Error Handling<ul> |
| <li>Support comprehensive error code if parsing failed.</li> |
| <li>Support error message localization.</li> |
| </ul> |
| </li> |
| </ul> |
| <h1><a class="anchor" id="autotoc_md40"></a> |
| DOM (Document)</h1> |
| <ul> |
| <li>RapidJSON checks range of numerical values for conversions.</li> |
| <li>Optimization for string literal<ul> |
| <li>Only store pointer instead of copying</li> |
| </ul> |
| </li> |
| <li>Optimization for "short" strings<ul> |
| <li>Store short string in <code>Value</code> internally without additional allocation.</li> |
| <li>For UTF-8 string: maximum 11 characters in 32-bit, 21 characters in 64-bit (13 characters in x86-64).</li> |
| </ul> |
| </li> |
| <li>Optionally support <code>std::string</code> (define <code>RAPIDJSON_HAS_STDSTRING=1</code>)</li> |
| </ul> |
| <h1><a class="anchor" id="autotoc_md41"></a> |
| Generation</h1> |
| <ul> |
| <li>Support <code><a class="el" href="classrapidjson_1_1_pretty_writer.html" title="Writer with indentation and spacing.">rapidjson::PrettyWriter</a></code> for adding newlines and indentations.</li> |
| </ul> |
| <h1><a class="anchor" id="autotoc_md42"></a> |
| Stream</h1> |
| <ul> |
| <li>Support <code><a class="el" href="classrapidjson_1_1_generic_string_buffer.html" title="Represents an in-memory output stream.">rapidjson::GenericStringBuffer</a></code> for storing the output JSON as string.</li> |
| <li>Support <code><a class="el" href="classrapidjson_1_1_file_read_stream.html" title="File byte stream for input using fread().">rapidjson::FileReadStream</a></code> and <code><a class="el" href="classrapidjson_1_1_file_write_stream.html" title="Wrapper of C file stream for output using fwrite().">rapidjson::FileWriteStream</a></code> for input/output <code>FILE</code> object.</li> |
| <li>Support custom streams.</li> |
| </ul> |
| <h1><a class="anchor" id="autotoc_md43"></a> |
| Memory</h1> |
| <ul> |
| <li>Minimize memory overheads for DOM.<ul> |
| <li>Each JSON value occupies exactly 16/20 bytes for most 32/64-bit machines (excluding text string).</li> |
| </ul> |
| </li> |
| <li>Support fast default allocator.<ul> |
| <li>A stack-based allocator (allocate sequentially, prohibit to free individual allocations, suitable for parsing).</li> |
| <li>User can provide a pre-allocated buffer. (Possible to parse a number of JSONs without any CRT allocation)</li> |
| </ul> |
| </li> |
| <li>Support standard CRT(C-runtime) allocator.</li> |
| <li>Support custom allocators.</li> |
| </ul> |
| <h1><a class="anchor" id="autotoc_md44"></a> |
| Miscellaneous</h1> |
| <ul> |
| <li>Some C++11 support (optional)<ul> |
| <li>Rvalue reference</li> |
| <li><code>noexcept</code> specifier</li> |
| <li>Range-based for loop </li> |
| </ul> |
| </li> |
| </ul> |
| </div></div><!-- contents --> |
| </div><!-- PageDoc --> |
| </div><!-- doc-content --> |
| <!-- HTML footer for doxygen 1.8.7--> |
| <!-- start footer part --> |
| <div id="nav-path" class="navpath"><!-- id is needed for treeview function! --> |
| <ul> |
| </ul> |
| </div> |
| </body> |
| </html> |