rapidjson/doc/features.md
2014-06-29 16:03:33 +08:00

2.7 KiB

RapidJSON Features

General

  • Cross-platform
  • Compiler: tested Visual Studio, gcc, clang
  • Architecture: x86, x64, ARM
  • Operating systems: Windows, Mac OS X, Linux, iOS, Android
  • Easy installation
  • Header files only library. Just copy the headers to your project.
  • Self-contained, minimal dependence
  • No STL, BOOST, etc.
  • Only included <cstdio>, <cstdlib>, <cstring>, <inttypes.h>, <new>, <stdint.h>.
  • High performance
  • Use template and inline functions to reduce function call overheads.
  • Optional SSE2/SSE4.1 support.

Standard compliance

  • RapidJSON should be fully RFC4627/ECMA-404 compliance.
  • Support unicode surrogate.
  • Support null character ("\u0000") ** For example, ["Hello\u0000World"] can be parsed and handled gracefully.

API style

  • SAX (Simple API for XML) style API
  • Similar to SAX, RapidJSON provides a event sequential access parser API (GenericReader). It also provides a generator API (GenericWriter) which consumes the same set of events.
  • DOM (Document Object Model) style API
  • Similar to DOM for HTML/XML, RapidJSON can parse JSON into a DOM representation (GenericDocument), for easy manipulation, and finally stringify back to JSON if needed.
  • The DOM style API (GenericDocument) is actually implemented with SAX style API (GenericReader). SAX is faster but sometimes DOM is easier. Users can pick their choices according to scenarios.

Unicode

  • 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 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 encodings.

Stream

  • Support GenericStringBuffer for storing the output JSON as string.
  • Support FileReadStream/FileWriteStream for input/output FILE object.
  • Support custom streams.

JSON formatting

  • Support PrettyWriter for adding newlines and indentations.

Memory

  • Minimize memory overheads for DOM.
  • Each JSON value occupies exactly 16/20 bytes for most 32/64-bit machines (excluding text string).
  • Support fast default allocator.
  • A stack-based allocator (allocate sequentially, prohibit to free individual allocations, suitable for parsing).
  • User can provide a pre-allocated buffer. (Possible to parse a number of JSONs without any CRT allocation)
  • Standard CRT(C-runtime) allocator.
  • Support custom allocators.