1
- Introduction
2
- ------------
1
+ # JsonCpp
3
2
4
3
[ JSON] [ json-org ] is a lightweight data-interchange format. It can represent
5
4
numbers, strings, ordered sequences of values, and collections of name/value
6
5
pairs.
7
6
8
7
[ json-org ] : http://json.org/
9
8
10
- [ JsonCpp] [ ] is a C++ library that allows manipulating JSON values, including
9
+ JsonCpp is a C++ library that allows manipulating JSON values, including
11
10
serialization and deserialization to and from strings. It can also preserve
12
11
existing comment in unserialization/serialization steps, making it a convenient
13
12
format to store user input files.
14
13
15
- [ JsonCpp ] : http://open-source-parsers.github.io/jsoncpp-docs/doxygen/index.html
14
+
15
+ ## Documentation
16
+
17
+ [ JsonCpp documentation] [ JsonCpp-documentation ] is generated using [ Doxygen] [ ] .
18
+
19
+ [ JsonCpp-documentation ] : http://open-source-parsers.github.io/jsoncpp-docs/doxygen/index.html
20
+ [ Doxygen ] : http://www.doxygen.org
21
+
16
22
17
23
## A note on backward-compatibility
24
+
18
25
* ` 1.y.z ` is built with C++11.
19
26
* ` 0.y.z ` can be used with older compilers.
20
27
* Major versions maintain binary-compatibility.
21
28
22
- # Using JsonCpp in your project
23
- -----------------------------
29
+
30
+ ## Using JsonCpp in your project
31
+
24
32
The recommended approach to integrating JsonCpp in your project is to include
25
33
the [ amalgamated source] ( #generating-amalgamated-source-and-header ) (a single
26
34
` .cpp ` file and two ` .h ` files) in your project, and compile and build as you
27
35
would any other source file. This ensures consistency of compilation flags and
28
36
ABI compatibility, issues which arise when building shared or static
29
37
libraries. See the next section for instructions.
30
38
31
- The ` include/ ` should be added to your compiler include path. Jsoncpp headers
39
+ The ` include/ ` should be added to your compiler include path. JsonCpp headers
32
40
should be included as follow:
33
41
34
42
#include <json/json.h>
35
43
36
- If JsonCpp was built as a dynamic library on Windows, then your project needs to
37
- define the macro ` JSON_DLL ` .
44
+ If JsonCpp was built as a dynamic library on Windows, then your project needs to define the macro ` JSON_DLL ` .
45
+
46
+ ### Generating amalgamated source and header
38
47
39
- Generating amalgamated source and header
40
- ----------------------------------------
41
48
JsonCpp is provided with a script to generate a single header and a single
42
49
source file to ease inclusion into an existing project. The amalgamated source
43
50
can be generated at any time by running the following command from the
@@ -48,6 +55,7 @@ top-directory (this requires Python 2.6):
48
55
It is possible to specify header name. See the ` -h ` option for detail.
49
56
50
57
By default, the following files are generated:
58
+
51
59
* ` dist/jsoncpp.cpp ` : source file that needs to be added to your project.
52
60
* ` dist/json/json.h ` : corresponding header file for use in your project. It is
53
61
equivalent to including ` json/json.h ` in non-amalgamated source. This header
@@ -56,15 +64,14 @@ By default, the following files are generated:
56
64
JsonCpp types.
57
65
58
66
The amalgamated sources are generated by concatenating JsonCpp source in the
59
- correct order and defining the macro ` JSON_IS_AMALGAMATION ` to prevent inclusion
60
- of other headers.
67
+ correct order and defining the macro ` JSON_IS_AMALGAMATION ` to prevent inclusion of other headers.
61
68
62
- # Contributing to JsonCpp
63
69
64
- Building and testing with CMake
65
- -------------------------------
66
- [ CMake] [ ] is a C++ Makefiles/Solution generator. It is usually available on most
67
- Linux system as package. On Ubuntu:
70
+ ## Contributing to JsonCpp
71
+
72
+ ### Building and testing with CMake
73
+
74
+ [ CMake] [ ] is a C++ Makefiles/Solution generator. It is usually available on most Linux system as package. On Ubuntu:
68
75
69
76
sudo apt-get install cmake
70
77
@@ -75,9 +82,9 @@ missing, the build will skip running those tests.
75
82
76
83
When running CMake, a few parameters are required:
77
84
78
- * a build directory where the makefiles/solution are generated. It is also used
85
+ * A build directory where the makefiles/solution are generated. It is also used
79
86
to store objects, libraries and executables files.
80
- * the generator to use: makefiles or Visual Studio solution? What version or
87
+ * The generator to use: makefiles or Visual Studio solution? What version or
81
88
Visual Studio, 32 or 64 bits solution?
82
89
83
90
Steps for generating solution/makefiles using ` cmake-gui ` :
@@ -107,10 +114,10 @@ the `-G` option).
107
114
By default CMake hides compilation commands. This can be modified by specifying
108
115
` -DCMAKE_VERBOSE_MAKEFILE=true ` when generating makefiles.
109
116
110
- Building and testing with SCons
111
- -------------------------------
112
- ** Note:** The SCons-based build system is deprecated. Please use CMake; see the
113
- section above.
117
+ ### Building and testing with SCons
118
+
119
+ ** Note:** The SCons-based build system is deprecated. Please use CMake ( see the
120
+ section above) .
114
121
115
122
JsonCpp can use [ Scons] [ ] as a build system. Note that SCons requires Python to
116
123
be installed.
@@ -137,7 +144,8 @@ If you are building with Microsoft Visual Studio 2008, you need to set up the
137
144
environment by running ` vcvars32.bat ` (e.g. MSVC 2008 command prompt) before
138
145
running SCons.
139
146
140
- ## Running the tests manually
147
+ ### Running the tests manually
148
+
141
149
You need to run tests manually only if you are troubleshooting an issue.
142
150
143
151
In the instructions below, replace ` path/to/jsontest ` with the path of the
@@ -160,21 +168,22 @@ In the instructions below, replace `path/to/jsontest` with the path of the
160
168
# You can run the tests using valgrind:
161
169
python rununittests.py --valgrind path/to/test_lib_json
162
170
163
- ## Running the tests using scons
171
+ ### Running the tests using SCons
172
+
164
173
Note that tests can be run using SCons using the ` check ` target:
165
174
166
175
scons platform=$PLATFORM check
167
176
168
- Building the documentation
169
- --------------------------
177
+ ### Building the documentation
178
+
170
179
Run the Python script ` doxybuild.py ` from the top directory:
171
180
172
181
python doxybuild.py --doxygen=$(which doxygen) --open --with-dot
173
182
174
183
See ` doxybuild.py --help ` for options.
175
184
176
- Adding a reader/writer test
177
- ---------------------------
185
+ ### Adding a reader/writer test
186
+
178
187
To add a test, you need to create two files in test/data:
179
188
180
189
* a ` TESTNAME.json ` file, that contains the input document in JSON format.
@@ -183,21 +192,19 @@ To add a test, you need to create two files in test/data:
183
192
184
193
The ` TESTNAME.expected ` file format is as follows:
185
194
186
- * each line represents a JSON element of the element tree represented by the
195
+ * Each line represents a JSON element of the element tree represented by the
187
196
input document.
188
- * each line has two parts: the path to access the element separated from the
197
+ * Each line has two parts: the path to access the element separated from the
189
198
element value by ` = ` . Array and object values are always empty (i.e.
190
199
represented by either ` [] ` or ` {} ` ).
191
- * element path: ` . ` represents the root element, and is used to separate object
200
+ * Element path ` . ` represents the root element, and is used to separate object
192
201
members. ` [N] ` is used to specify the value of an array element at index ` N ` .
193
202
194
- See the examples ` test_complex_01.json ` and ` test_complex_01.expected ` to better
195
- understand element paths.
203
+ See the examples ` test_complex_01.json ` and ` test_complex_01.expected ` to better understand element paths.
196
204
197
- Understanding reader/writer test output
198
- ---------------------------------------
199
- When a test is run, output files are generated beside the input test files.
200
- Below is a short description of the content of each file:
205
+ ### Understanding reader/writer test output
206
+
207
+ When a test is run, output files are generated beside the input test files. Below is a short description of the content of each file:
201
208
202
209
* ` test_complex_01.json ` : input JSON document.
203
210
* ` test_complex_01.expected ` : flattened JSON element tree used to check if
@@ -212,7 +219,7 @@ Below is a short description of the content of each file:
212
219
* ` test_complex_01.process-output ` : ` jsontest ` output, typically useful for
213
220
understanding parsing errors.
214
221
215
- License
216
- -------
222
+ ## License
223
+
217
224
See the ` LICENSE ` file for details. In summary, JsonCpp is licensed under the
218
225
MIT license, or public domain if desired and recognized in your jurisdiction.
0 commit comments