1 # Features 2 3 ## General 4 5 * Cross-platform 6 * Compilers: Visual Studio, gcc, clang, etc. 7 * Architectures: x86, x64, ARM, etc. 8 * Operating systems: Windows, Mac OS X, Linux, iOS, Android, etc. 9 * Easy installation 10 * Header files only library. Just copy the headers to your project. 11 * Self-contained, minimal dependences 12 * No STL, BOOST, etc. 13 * Only included `<cstdio>`, `<cstdlib>`, `<cstring>`, `<inttypes.h>`, `<new>`, `<stdint.h>`. 14 * Without C++ exception, RTTI 15 * High performance 16 * Use template and inline functions to reduce function call overheads. 17 * Internal optimized Grisu2 and floating point parsing implementations. 18 * Optional SSE2/SSE4.2 support. 19 20 ## Standard compliance 21 22 * RapidJSON should be fully RFC4627/ECMA-404 compliance. 23 * Support Unicode surrogate. 24 * Support null character (`"\u0000"`) 25 * For example, `["Hello\u0000World"]` can be parsed and handled gracefully. There is API for getting/setting lengths of string. 26 27 ## Unicode 28 29 * Support UTF-8, UTF-16, UTF-32 encodings, including little endian and big endian. 30 * These encodings are used in input/output streams and in-memory representation. 31 * Support automatic detection of encodings in input stream. 32 * Support transcoding between encodings internally. 33 * For example, you can read a UTF-8 file and let RapidJSON transcode the JSON strings into UTF-16 in the DOM. 34 * Support encoding validation internally. 35 * For example, you can read a UTF-8 file, and let RapidJSON check whether all JSON strings are valid UTF-8 byte sequence. 36 * Support custom character types. 37 * By default the character types are `char` for UTF8, `wchar_t` for UTF16, `uint32_t` for UTF32. 38 * Support custom encodings. 39 40 ## API styles 41 42 * SAX (Simple API for XML) style API 43 * Similar to [SAX](http://en.wikipedia.org/wiki/Simple_API_for_XML), RapidJSON provides a event sequential access parser API (`rapidjson::GenericReader`). It also provides a generator API (`rapidjson::Writer`) which consumes the same set of events. 44 * DOM (Document Object Model) style API 45 * Similar to [DOM](http://en.wikipedia.org/wiki/Document_Object_Model) for HTML/XML, RapidJSON can parse JSON into a DOM representation (`rapidjson::GenericDocument`), for easy manipulation, and finally stringify back to JSON if needed. 46 * The DOM style API (`rapidjson::GenericDocument`) is actually implemented with SAX style API (`rapidjson::GenericReader`). SAX is faster but sometimes DOM is easier. Users can pick their choices according to scenarios. 47 48 ## Parsing 49 50 * Recursive (default) and iterative parser 51 * Recursive parser is faster but prone to stack overflow in extreme cases. 52 * Iterative parser use custom stack to keep parsing state. 53 * Support *in situ* parsing. 54 * Parse JSON string values in-place at the source JSON, and then the DOM points to addresses of those strings. 55 * Faster than convention parsing: no allocation for strings, no copy (if string does not contain escapes), cache-friendly. 56 * Support 32-bit/64-bit signed/unsigned integer and `double` for JSON number type. 57 * Support parsing multiple JSONs in input stream (`kParseStopWhenDoneFlag`). 58 * Error Handling 59 * Support comprehensive error code if parsing failed. 60 * Support error message localization. 61 62 ## DOM (Document) 63 64 * RapidJSON checks range of numerical values for conversions. 65 * Optimization for string literal 66 * Only store pointer instead of copying 67 * Optimization for "short" strings 68 * Store short string in `Value` internally without additional allocation. 69 * For UTF-8 string: maximum 11 characters in 32-bit, 15 characters in 64-bit. 70 * Optionally support `std::string` (define `RAPIDJSON_HAS_STDSTRING=1`) 71 72 ## Generation 73 74 * Support `rapidjson::PrettyWriter` for adding newlines and indentations. 75 76 ## Stream 77 78 * Support `rapidjson::GenericStringBuffer` for storing the output JSON as string. 79 * Support `rapidjson::FileReadStream` and `rapidjson::FileWriteStream` for input/output `FILE` object. 80 * Support custom streams. 81 82 ## Memory 83 84 * Minimize memory overheads for DOM. 85 * Each JSON value occupies exactly 16/20 bytes for most 32/64-bit machines (excluding text string). 86 * Support fast default allocator. 87 * A stack-based allocator (allocate sequentially, prohibit to free individual allocations, suitable for parsing). 88 * User can provide a pre-allocated buffer. (Possible to parse a number of JSONs without any CRT allocation) 89 * Support standard CRT(C-runtime) allocator. 90 * Support custom allocators. 91 92 ## Miscellaneous 93 94 * Some C++11 support (optional) 95 * Rvalue reference 96 * `noexcept` specifier 97