4
4
5
5
<a HREF="http://www.json.org/">JSON (JavaScript Object Notation)</a>
6
6
is a lightweight data-interchange format.
7
- It can represent integer, real number, string, an ordered sequence of value, and
8
- a collection of name/value pairs.
9
7
10
8
Here is an example of JSON data:
11
9
\verbatim
10
+ {
11
+ "encoding" : "UTF-8",
12
+ "plug-ins" : [
13
+ "python",
14
+ "c++",
15
+ "ruby"
16
+ ],
17
+ "indent" : { "length" : 3, "use_space": true }
18
+ }
19
+ \endverbatim
20
+ <b>JsonCpp</b> supports comments as <i>meta-data</i>:
21
+ \code
12
22
// Configuration options
13
23
{
14
24
// Default encoding for text
@@ -17,30 +27,30 @@ Here is an example of JSON data:
17
27
// Plug-ins loaded at start-up
18
28
"plug-ins" : [
19
29
"python",
20
- "c++",
30
+ "c++", // trailing comment
21
31
"ruby"
22
32
],
23
33
24
34
// Tab indent size
25
- "indent" : { "length" : 3, "use_space": true }
35
+ // (multi-line comment)
36
+ "indent" : { /*embedded comment*/ "length" : 3, "use_space": true }
26
37
}
27
- \endverbatim
28
- <code>jsoncpp</code> supports comments as <i>meta-data</i>.
38
+ \endcode
29
39
30
40
\section _features Features
31
41
- read and write JSON document
32
42
- attach C++ style comments to element during parsing
33
43
- rewrite JSON document preserving original comments
34
44
35
- Notes: Comments used to be supported in JSON but where removed for
45
+ Notes: Comments used to be supported in JSON but were removed for
36
46
portability (C like comments are not supported in Python). Since
37
47
comments are useful in configuration/input file, this feature was
38
48
preserved.
39
49
40
50
\section _example Code example
41
51
42
52
\code
43
- Json::Value root; // will contains the root value after parsing.
53
+ Json::Value root; // will contain the root value after parsing.
44
54
Json::Reader reader;
45
55
bool parsingSuccessful = reader.parse( config_doc, root );
46
56
if ( !parsingSuccessful )
0 commit comments