2007-06-14 21:01:26 +00:00
|
|
|
* Introduction:
|
2010-02-22 04:16:10 +00:00
|
|
|
=============
|
2007-06-14 21:01:26 +00:00
|
|
|
|
|
|
|
JSON (JavaScript Object Notation) is a lightweight data-interchange format.
|
|
|
|
It can represent integer, real number, string, an ordered sequence of
|
|
|
|
value, and a collection of name/value pairs.
|
|
|
|
|
2010-02-22 04:16:10 +00:00
|
|
|
JsonCpp is a simple API to manipulate JSON value, handle serialization
|
2007-06-14 21:01:26 +00:00
|
|
|
and unserialization to string.
|
|
|
|
|
|
|
|
It can also preserve existing comment in unserialization/serialization steps,
|
|
|
|
making it a convenient format to store user input files.
|
|
|
|
|
|
|
|
Unserialization parsing is user friendly and provides precise error reports.
|
|
|
|
|
2010-02-22 04:16:10 +00:00
|
|
|
|
2007-06-14 21:01:26 +00:00
|
|
|
* Building/Testing:
|
2010-02-22 04:16:10 +00:00
|
|
|
=================
|
2007-06-14 21:01:26 +00:00
|
|
|
|
|
|
|
JsonCpp uses Scons (http://www.scons.org) as a build system. Scons requires
|
|
|
|
python to be installed (http://www.python.org).
|
|
|
|
|
|
|
|
You download scons-local distribution from the following url:
|
2011-05-01 15:06:40 +00:00
|
|
|
http://sourceforge.net/projects/scons/files/scons-local/1.2.0/
|
2007-06-14 21:01:26 +00:00
|
|
|
|
|
|
|
Unzip it in the directory where you found this README file. scons.py Should be
|
|
|
|
at the same level as README.
|
|
|
|
|
|
|
|
python scons.py platform=PLTFRM [TARGET]
|
|
|
|
where PLTFRM may be one of:
|
|
|
|
suncc Sun C++ (Solaris)
|
|
|
|
vacpp Visual Age C++ (AIX)
|
|
|
|
mingw
|
|
|
|
msvc6 Microsoft Visual Studio 6 service pack 5-6
|
|
|
|
msvc70 Microsoft Visual Studio 2002
|
|
|
|
msvc71 Microsoft Visual Studio 2003
|
|
|
|
msvc80 Microsoft Visual Studio 2005
|
2010-03-13 10:59:50 +00:00
|
|
|
msvc90 Microsoft Visual Studio 2008
|
2007-06-14 21:01:26 +00:00
|
|
|
linux-gcc Gnu C++ (linux, also reported to work for Mac OS X)
|
2010-03-13 10:59:50 +00:00
|
|
|
|
|
|
|
Notes: if you are building with Microsoft Visual Studio 2008, you need to
|
|
|
|
setup the environment by running vcvars32.bat (e.g. MSVC 2008 command prompt)
|
|
|
|
before running scons.
|
2007-06-14 21:01:26 +00:00
|
|
|
|
2010-03-13 10:59:50 +00:00
|
|
|
Adding platform is fairly simple. You need to change the Sconstruct file
|
2007-06-14 21:01:26 +00:00
|
|
|
to do so.
|
|
|
|
|
|
|
|
and TARGET may be:
|
|
|
|
check: build library and run unit tests.
|
|
|
|
|
2010-02-22 04:16:10 +00:00
|
|
|
|
|
|
|
* Running the test manually:
|
|
|
|
==========================
|
|
|
|
|
2011-05-01 15:06:40 +00:00
|
|
|
Notes that test can be run by scons using the 'check' target (see above).
|
|
|
|
|
|
|
|
You need to run test manually only if you are troubleshooting an issue.
|
|
|
|
|
|
|
|
In the instruction below, replace "path to jsontest.exe" with the path
|
|
|
|
of the 'jsontest' executable that was compiled on your platform.
|
|
|
|
|
2009-11-18 21:38:54 +00:00
|
|
|
cd test
|
2009-11-22 13:11:14 +00:00
|
|
|
# This will run the Reader/Writer tests
|
2009-11-18 21:38:54 +00:00
|
|
|
python runjsontests.py "path to jsontest.exe"
|
2010-02-22 04:16:10 +00:00
|
|
|
|
|
|
|
# This will run the Reader/Writer tests, using JSONChecker test suite
|
|
|
|
# (http://www.json.org/JSON_checker/).
|
|
|
|
# Notes: not all tests pass: JsonCpp is too lenient (for example,
|
|
|
|
# it allows an integer to start with '0'). The goal is to improve
|
|
|
|
# strict mode parsing to get all tests to pass.
|
|
|
|
python runjsontests.py --with-json-checker "path to jsontest.exe"
|
|
|
|
|
2009-11-22 13:11:14 +00:00
|
|
|
# This will run the unit tests (mostly Value)
|
|
|
|
python rununittests.py "path to test_lib_json.exe"
|
|
|
|
|
2010-02-22 04:16:10 +00:00
|
|
|
You can run the tests using valgrind:
|
2009-11-22 13:11:14 +00:00
|
|
|
python rununittests.py --valgrind "path to test_lib_json.exe"
|
2010-02-22 04:16:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
* Building the documentation:
|
|
|
|
===========================
|
|
|
|
|
|
|
|
Run the python script doxybuild.py from the top directory:
|
|
|
|
|
|
|
|
python doxybuild.py --open --with-dot
|
|
|
|
|
|
|
|
See doxybuild.py --help for options.
|
|
|
|
|
2010-04-27 16:38:30 +00:00
|
|
|
Notes that the documentation is also available for download as a tarball.
|
|
|
|
The documentation of the latest release is available online at:
|
|
|
|
http://jsoncpp.sourceforge.net/
|
|
|
|
|
2010-02-22 04:16:10 +00:00
|
|
|
|
|
|
|
* Adding a reader/writer test:
|
|
|
|
============================
|
|
|
|
|
|
|
|
To add a test, you need to create two files in test/data:
|
|
|
|
- a TESTNAME.json file, that contains the input document in JSON format.
|
|
|
|
- a TESTNAME.expected file, that contains a flatened representation of
|
|
|
|
the input document.
|
|
|
|
|
|
|
|
TESTNAME.expected file format:
|
|
|
|
- each line represents a JSON element of the element tree represented
|
|
|
|
by the input document.
|
|
|
|
- each line has two parts: the path to access the element separated from
|
|
|
|
the element value by '='. Array and object values are always empty
|
|
|
|
(e.g. represented by either [] or {}).
|
|
|
|
- element path: '.' represented the root element, and is used to separate
|
|
|
|
object members. [N] is used to specify the value of an array element
|
|
|
|
at index N.
|
|
|
|
See test_complex_01.json and test_complex_01.expected to better understand
|
|
|
|
element path.
|
|
|
|
|
|
|
|
|
|
|
|
* Understanding reader/writer test output:
|
|
|
|
========================================
|
|
|
|
|
|
|
|
When a test is run, output files are generated aside the input test files.
|
|
|
|
Below is a short description of the content of each file:
|
|
|
|
|
|
|
|
- test_complex_01.json: input JSON document
|
|
|
|
- test_complex_01.expected: flattened JSON element tree used to check if
|
|
|
|
parsing was corrected.
|
|
|
|
|
|
|
|
- test_complex_01.actual: flattened JSON element tree produced by
|
|
|
|
jsontest.exe from reading test_complex_01.json
|
|
|
|
- test_complex_01.rewrite: JSON document written by jsontest.exe using the
|
|
|
|
Json::Value parsed from test_complex_01.json and serialized using
|
|
|
|
Json::StyledWritter.
|
|
|
|
- test_complex_01.actual-rewrite: flattened JSON element tree produced by
|
|
|
|
jsontest.exe from reading test_complex_01.rewrite.
|
|
|
|
test_complex_01.process-output: jsontest.exe output, typically useful to
|
|
|
|
understand parsing error.
|
2010-04-20 21:35:19 +00:00
|
|
|
|
|
|
|
* License
|
|
|
|
=======
|
|
|
|
|
|
|
|
See file LICENSE for details. Basically JsonCpp is licensed under
|
|
|
|
MIT license, or public domain if desired and recognized in your jurisdiction.
|