ENH: Refactor and enhance the CI testing infrastructure 1) Improve travis build script for use outside travis. Allow the script used for CI builds to also be used locally in a similar manner to the CI use of the scrips 2) Add ctest compatible testing and CDASH support Report testing and building results to https://my.cdash.org/index.php?project=jsoncpp NOTE: The new ctest infrastructure is not yet robust on winodws Do no yet enable the new features for running test with ctest on windows platform. The previous behaviors are maintainted, but enhance test reporting from windows is not yet supported. 3) Add a cmake coverage testing option Ensure that cmake builds on linux are tested. Ensure that code coverage is reported. 4) Move conditional environment checking into the matrix Avoid multiple places where conditional logic is used to change compiler behavior. As more test environments are created fromt the travis.yml matrix, all settings should be obvious from that one location. 5) Tests with known regressions from the jsonchecker are suppressed Tests that are known to pass with jsoncpp more lenient syntax enforcement are exluded from tests in test/runjsontests.py
JSON is a lightweight data-interchange format. It can represent numbers, strings, ordered sequences of values, and collections of name/value pairs.
JsonCpp is a C++ library that allows manipulating JSON values, including serialization and deserialization to and from strings. It can also preserve existing comment in unserialization/serialization steps, making it a convenient format to store user input files.
JsonCpp documentation is generated using Doxygen.
1.y.z is built with C++11.0.y.z can be used with older compilers.Thanks to David Seifert (@SoapGentoo), we (the maintainers) now use meson and ninja to build for debugging, as well as for continuous integration (see ./travis_scripts/meson_builder.sh ). Other systems may work, but minor things like version strings might break.
First, install both meson (which requires Python3) and ninja. If you wish to install to a directory other than /usr/local, set an environment variable called DESTDIR with the desired path: DESTDIR=/path/to/install/dir
Then,
cd jsoncpp/
BUILD_TYPE=debug
#BUILD_TYPE=release
LIB_TYPE=shared
#LIB_TYPE=static
meson --buildtype ${BUILD_TYPE} --default-library ${LIB_TYPE} . build-${LIB_TYPE}
#ninja -v -C build-${LIB_TYPE} test # This stopped working on my Mac.
ninja -v -C build-${LIB_TYPE}
cd build-${LIB_TYPE}
meson test --no-rebuild --print-errorlogs
sudo ninja install
See https://github.com/open-source-parsers/jsoncpp/wiki/Building
You need to run tests manually only if you are troubleshooting an issue.
In the instructions below, replace path/to/jsontest with the path of the jsontest executable that was compiled on your platform.
cd test # This will run the Reader/Writer tests python runjsontests.py path/to/jsontest # 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 # This will run the unit tests (mostly Value) python rununittests.py path/to/test_lib_json # You can run the tests using valgrind: python rununittests.py --valgrind path/to/test_lib_json
Run the Python script doxybuild.py from the top directory:
python doxybuild.py --doxygen=$(which doxygen) --open --with-dot
See doxybuild.py --help for options.
To add a test, you need to create two files in test/data:
TESTNAME.json file, that contains the input document in JSON format.TESTNAME.expected file, that contains a flatened representation of the input document.The TESTNAME.expected file format is as follows:
=. Array and object values are always empty (i.e. represented by either [] or {}).. represents 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 the examples test_complex_01.json and test_complex_01.expected to better understand element paths.
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:
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 from reading test_complex_01.json.test_complex_01.rewrite: JSON document written by jsontest 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 from reading test_complex_01.rewrite.test_complex_01.process-output: jsontest output, typically useful for understanding parsing errors.https://github.com/open-source-parsers/jsoncpp/wiki/Amalgamated
If you are using the Meson Build System, then you can get a wrap file by downloading it from Meson WrapDB, or simply use meson wrap install jsoncpp.
If you have trouble, see the Wiki, or post a question as an Issue.
See the LICENSE file for details. In summary, JsonCpp is licensed under the MIT license, or public domain if desired and recognized in your jurisdiction.