• Home
  • History
  • Annotate
  • only in /packages/apps/Test/connectivity/sl4n/rapidjson/
NameDateSize

..11-Jun-20184 KiB

.gitignore11-Jun-2018314

.gitmodules11-Jun-2018121

bin/11-Jun-20184 KiB

CHANGELOG.md11-Jun-20182.8 KiB

CMakeModules/11-Jun-20184 KiB

doc/11-Jun-20184 KiB

example/11-Jun-20184 KiB

include/11-Jun-20184 KiB

library.json11-Jun-2018313

readme.md11-Jun-20185.8 KiB

test/11-Jun-20184 KiB

readme.md

1![](doc/logo/rapidjson.png)
2
3![](https://img.shields.io/badge/release-v1.0.2-blue.png)
4
5## A fast JSON parser/generator for C++ with both SAX/DOM style API 
6
7Tencent is pleased to support the open source community by making RapidJSON available.
8
9Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
10
11* [RapidJSON GitHub](https://github.com/miloyip/rapidjson/)
12* RapidJSON Documentation
13  * [English](http://rapidjson.org/)
14  * [简体中文](http://rapidjson.org/zh-cn/)
15  * [GitBook](https://www.gitbook.com/book/miloyip/rapidjson/) with downloadable PDF/EPUB/MOBI, without API reference.
16
17## Build status
18
19| [Linux][lin-link] | [Windows][win-link] | [Coveralls][cov-link] |
20| :---------------: | :-----------------: | :-------------------: |
21| ![lin-badge]      | ![win-badge]        | ![cov-badge]          |
22
23[lin-badge]: https://travis-ci.org/miloyip/rapidjson.png?branch=master "Travis build status"
24[lin-link]:  https://travis-ci.org/miloyip/rapidjson "Travis build status"
25[win-badge]: https://ci.appveyor.com/api/projects/status/u658dcuwxo14a8m9/branch/master "AppVeyor build status"
26[win-link]:  https://ci.appveyor.com/project/miloyip/rapidjson/branch/master "AppVeyor build status"
27[cov-badge]: https://coveralls.io/repos/miloyip/rapidjson/badge.png?branch=master
28[cov-link]:  https://coveralls.io/r/miloyip/rapidjson?branch=master
29
30## Introduction
31
32RapidJSON is a JSON parser and generator for C++. It was inspired by [RapidXml](http://rapidxml.sourceforge.net/).
33
34* RapidJSON is small but complete. It supports both SAX and DOM style API. The SAX parser is only a half thousand lines of code.
35
36* RapidJSON is fast. Its performance can be comparable to `strlen()`. It also optionally supports SSE2/SSE4.2 for acceleration.
37
38* RapidJSON is self-contained. It does not depend on external libraries such as BOOST. It even does not depend on STL.
39
40* RapidJSON is memory friendly. Each JSON value occupies exactly 16/20 bytes for most 32/64-bit machines (excluding text string). By default it uses a fast memory allocator, and the parser allocates memory compactly during parsing.
41
42* RapidJSON is Unicode friendly. It supports UTF-8, UTF-16, UTF-32 (LE & BE), and their detection, validation and transcoding internally. For example, you can read a UTF-8 file and let RapidJSON transcode the JSON strings into UTF-16 in the DOM. It also supports surrogates and "\u0000" (null character).
43
44More features can be read [here](doc/features.md).
45
46JSON(JavaScript Object Notation) is a light-weight data exchange format. RapidJSON should be in fully compliance with RFC7159/ECMA-404. More information about JSON can be obtained at
47* [Introducing JSON](http://json.org/)
48* [RFC7159: The JavaScript Object Notation (JSON) Data Interchange Format](http://www.ietf.org/rfc/rfc7159.txt)
49* [Standard ECMA-404: The JSON Data Interchange Format](http://www.ecma-international.org/publications/standards/Ecma-404.htm)
50
51## Compatibility
52
53RapidJSON is cross-platform. Some platform/compiler combinations which have been tested are shown as follows.
54* Visual C++ 2008/2010/2013 on Windows (32/64-bit)
55* GNU C++ 3.8.x on Cygwin
56* Clang 3.4 on Mac OS X (32/64-bit) and iOS
57* Clang 3.4 on Android NDK
58
59Users can build and run the unit tests on their platform/compiler.
60
61## Installation
62
63RapidJSON is a header-only C++ library. Just copy the `include/rapidjson` folder to system or project's include path.
64
65RapidJSON uses following software as its dependencies:
66* [CMake](http://www.cmake.org) as a general build tool
67* (optional)[Doxygen](http://www.doxygen.org) to build documentation
68* (optional)[googletest](https://code.google.com/p/googletest/) for unit and performance testing
69
70To generate user documentation and run tests please proceed with the steps below:
71
721. Execute `git submodule update --init` to get the files of thirdparty submodules (google test).
732. Create directory called `build` in rapidjson source directory.
743. Change to `build` directory and run `cmake ..` command to configure your build. Windows users can do the same with cmake-gui application.
754. On Windows, build the solution found in the build directory. On Linux, run `make` from the build directory.
76
77On successfull build you will find compiled test and example binaries in `bin`
78directory. The generated documentation will be available in `doc/html`
79directory of the build tree. To run tests after finished build please run `make
80test` or `ctest` from your build tree. You can get detailed output using `ctest
81-V` command.
82
83It is possible to install library system-wide by running `make install` command
84from the build tree with administrative privileges. This will install all files
85according to system preferences.  Once RapidJSON is installed, it is possible
86to use it from other CMake projects by adding `find_package(RapidJSON)` line to
87your CMakeLists.txt.
88
89## Usage at a glance
90
91This simple example parses a JSON string into a document (DOM), make a simple modification of the DOM, and finally stringify the DOM to a JSON string.
92
93~~~~~~~~~~cpp
94// rapidjson/example/simpledom/simpledom.cpp`
95#include "rapidjson/document.h"
96#include "rapidjson/writer.h"
97#include "rapidjson/stringbuffer.h"
98#include <iostream>
99
100using namespace rapidjson;
101
102int main() {
103    // 1. Parse a JSON string into DOM.
104    const char* json = "{\"project\":\"rapidjson\",\"stars\":10}";
105    Document d;
106    d.Parse(json);
107
108    // 2. Modify it by DOM.
109    Value& s = d["stars"];
110    s.SetInt(s.GetInt() + 1);
111
112    // 3. Stringify the DOM
113    StringBuffer buffer;
114    Writer<StringBuffer> writer(buffer);
115    d.Accept(writer);
116
117    // Output {"project":"rapidjson","stars":11}
118    std::cout << buffer.GetString() << std::endl;
119    return 0;
120}
121~~~~~~~~~~
122
123Note that this example did not handle potential errors.
124
125The following diagram shows the process.
126
127![simpledom](doc/diagram/simpledom.png)
128
129More [examples](https://github.com/miloyip/rapidjson/tree/master/example) are available.
130