Introduction to RapidJSON
Latest Updates
- [2026-06-30] Released fast-path optimizations for string parsing and serialization, improving the performance of parsing UTF-8 memory input and generating
StringBufferoutput.
Project Introduction
Overview
RapidJSON is a high-performance, lightweight, and header-only C++ JSON parser and generator. It is open sourced by Tencent, supporting both SAX and DOM styles. Independent of external libraries like STL or Boost, RapidJSON is ideal for JSON data parsing, construction, validation, and serialization in server-side, embedded, and performance-sensitive scenarios. Its core advantages include simple interfaces, low memory footprint, excellent cross-platform capability, and support for handling UTF-8, UTF-16, and UTF-32 encoding.
Core Modules
RapidJSON is divided into core modules including the Reader module, DOM module, Writer module, and helper utility modules.
- Reader module: Provides SAX-style streaming JSON parsing capability, responsible for lexical scan, string decoding, numeric parsing, and event dispatch.
- Document/Value DOM module: Provides capabilities for building, querying, modifying, copying, and managing memory allocation for the JSON object tree.
- Writer module: Provides serialization capability from SAX events to JSON text, supporting both compact and formatted output.
- Stream module: Abstracts input and output channels such as memory, files, and strings to support the parsing and writing processes.
- Encoding module: Provides UTF-8, UTF-16, and UTF-32 encoding conversion and validation capabilities.
- Schema validation module: Supports JSON schema validation for checking JSON data structures and constraints.
Core External API Functions
The following lists the core external API functions of RapidJSON (using C++ as an example), covering core capabilities such as DOM parsing, SAX parsing, JSON serialization, and schema validation.
| Module | Function/Method | Description |
|---|---|---|
| DOM parsing | Document::Parse |
Parses a JSON string into a DOM object tree. |
| DOM parsing | Document::ParseStream |
Parses JSON data from an input stream. |
| DOM access | Value::FindMember |
Queries an object member and returns an iterator. |
| DOM access | Value::GetArray |
Obtains an array view and iterates through array elements. |
| DOM modification | Value::AddMember |
Adds a key-value member to an object. |
| DOM modification | Value::PushBack |
Appends an element to an array. |
| Serialization | Writer::String |
Writes a JSON string value. |
| Serialization | Writer::WriteString |
Escapes string content and outputs it to the target stream. |
| Serialization | PrettyWriter |
Generates formatted JSON text with indentations and line breaks. |
| Stream processing | StringBuffer::GetString |
Obtains the serialized JSON string. |
| Stream processing | MemoryStream |
Reads JSON input from a memory buffer. |
| Schema validation | SchemaDocument |
Constructs a JSON Schema document. |
| Schema validation | SchemaValidator |
Validates whether JSON data conforms to the schema. |
Directory Structure
The project directory structure is as follows:
# Documentation directory
README_EN.md # Project description
LICENSE # Code license
kunpeng_opti_v1.0.0.patch # Optimization patch generated based on dev and master branches
docs/
├── LICENSE # Document license
└── en/
├── api_reference.md # API reference
├── installation_guide.md # Installation guide
├── menu_rapidjson.md # Documentation navigation
├── quick_start.md # Quick start guide
└── release_notes.md # Release notes
# Code directory (dev branch)
rapidjson/
├── include/rapidjson/ # Header-only core header files
│ ├── reader.h # SAX parser and string scan logic
│ ├── writer.h # JSON writer and string serialization logic
│ ├── document.h # DOM document/value definitions
│ ├── stringbuffer.h # Memory output buffer
│ ├── memorystream.h # Memory input stream
│ └── ...
├── example/ # Usage examples
├── test/ # Unit tests and performance tests
├── doc/ # Upstream documentation
├── bin/ # Test data
├── CMakeLists.txt # CMake build file
└── readme.md # Upstream project introductionVersion Description
For details about the feature changes in each release of the RapidJSON version optimized for Kunpeng, see Release Notes.
Environment Deployment
For details about the compilation environment, dependency obtaining, and installation procedure of Kunpeng-optimized RapidJSON, see Installation Guide.
Quick Start
For details about how to quickly get started with RapidJSON, see Quick Start.
Documentation
| Document Name | Description |
|---|---|
| Release Notes | Provides basic information and feature updates of each release of Kunpeng-optimized RapidJSON. |
| Quick Start | Provides quick start examples and compilation instructions for Kunpeng-optimized RapidJSON. |
| API Reference | Provides descriptions and definitions of APIs for string parsing and serialization optimization. |
| Installation Guide | Provides detailed instructions on configuring, compiling, and installing Kunpeng-optimized RapidJSON. |
Disclaimer
To RapidJSON Users
This software is intended solely for debugging and development. You are responsible for any risks and should carefully review the following information:
- This code repository contributes to the RapidJSON open-source project solely for performance optimization of certain RapidJSON functions on Kunpeng processors. It strictly adheres to the coding style and methods, as well as security design of the original open-source software. Any vulnerability and security issues of the software shall be resolved by the corresponding upstream communities according to their response mechanisms. Please pay attention to the notifications and version updates released by the upstream communities. The Kunpeng computing community does not assume any responsibility for software vulnerabilities and security issues.
- Data processing and deletion: Users are responsible for managing and deleting any data generated while using this software. You are advised to promptly delete any related data after use to prevent information leaks.
- Data confidentiality and transmission: Users understand and agree not to share or transmit any data generated by this software. Neither the software nor its developers are responsible for any information leaks, data breaches, or other negative consequences.
- User input security: Users are responsible for the security of any JSON data, file paths, and command-line parameters they enter, and for any security risks or losses resulting from improper input. The software and its developers are not liable for issues caused by improper input.
Disclaimer scope: This disclaimer applies to all individuals and entities using this software. By using the software, you acknowledge and accept this statement and assume all risks and responsibilities arising from its use. If you do not agree, please stop using the software immediately.
Before using this software, please read and understand the preceding disclaimer. If you have any questions, contact the developer.
To Data Owners
If you do not want your dataset to be mentioned in the RapidJSON optimization repository, or if you wish to update its description, please submit an issue on GitCode. We will delete or update your description according to your request. Thank you for your understanding and support.
License
RapidJSON is licensed under the MIT License. For details, see LICENSE.
The documents of this project are licensed under CC-BY 4.0. For details, see LICENSE.
Contribution Statement
We welcome your contributions to the community. If you have any questions/suggestions or want to provide feedback on feature requirements and bug reports, you can submit issues. For details, see Contribution Guideline. You are also welcome to share insights in Discussions. Thank you for your support.
Acknowledgments
RapidJSON is jointly developed by the following Huawei department:
- Kunpeng Computing BoostKit Development Dept
Thank you to everyone in the community for your PRs. We warmly welcome contributions to RapidJSON!