Support UTF-8, UTF-16, UTF-32 encodings, including little endian and big endian.
These encodings are used in input/output streams and in-memory representation.
Support automatic detection of encodings in input stream.
Support transcoding between encodings internally.
For example, you can read a UTF-8 file and let RapidJSON transcode the JSON strings into UTF-16 in the DOM.
Support encoding validation internally.
For example, you can read a UTF-8 file, and let RapidJSON check whether all JSON strings are valid UTF-8 byte sequence.
Support custom character types.
By default the character types are char for UTF8, wchar_t for UTF16, uint32_t for UTF32.
Support custom encodings.
API styles
SAX (Simple API for XML) style API
Similar to SAX, 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.
Similar to DOM for HTML/XML, RapidJSON can parse JSON into a DOM representation (rapidjson::GenericDocument), for easy manipulation, and finally stringify back to JSON if needed.
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.
Parsing
Recursive (default) and iterative parser
Recursive parser is faster but prone to stack overflow in extreme cases.
Iterative parser use custom stack to keep parsing state.
Support in situ parsing.
Parse JSON string values in-place at the source JSON, and then the DOM points to addresses of those strings.
Faster than convention parsing: no allocation for strings, no copy (if string does not contain escapes), cache-friendly.
Support 32-bit/64-bit signed/unsigned integer and double for JSON number type.