Skip to content

Commit 746ef15

Browse files
author
paulo
committed
Including instructions in how to use jsonCpp with conan
Also added the badge to the conan package. Related to issue open-source-parsers#564
1 parent 559b441 commit 746ef15

File tree

1 file changed

+47
-8
lines changed

1 file changed

+47
-8
lines changed

README.md

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# JsonCpp
22

3+
[![badge](https://img.shields.io/badge/conan.io-jsoncpp%2F1.8.0-green.svg?logo=data:image/png;base64%2CiVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAMAAAAolt3jAAAA1VBMVEUAAABhlctjlstkl8tlmMtlmMxlmcxmmcxnmsxpnMxpnM1qnc1sn85voM91oM11oc1xotB2oc56pNF6pNJ2ptJ8ptJ8ptN9ptN8p9N5qNJ9p9N9p9R8qtOBqdSAqtOAqtR%2BrNSCrNJ/rdWDrNWCsNWCsNaJs9eLs9iRvNuVvdyVv9yXwd2Zwt6axN6dxt%2Bfx%2BChyeGiyuGjyuCjyuGly%2BGlzOKmzOGozuKoz%2BKqz%2BOq0OOv1OWw1OWw1eWx1eWy1uay1%2Baz1%2Baz1%2Bez2Oe02Oe12ee22ujUGwH3AAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfgBQkREyOxFIh/AAAAiklEQVQI12NgAAMbOwY4sLZ2NtQ1coVKWNvoc/Eq8XDr2wB5Ig62ekza9vaOqpK2TpoMzOxaFtwqZua2Bm4makIM7OzMAjoaCqYuxooSUqJALjs7o4yVpbowvzSUy87KqSwmxQfnsrPISyFzWeWAXCkpMaBVIC4bmCsOdgiUKwh3JojLgAQ4ZCE0AMm2D29tZwe6AAAAAElFTkSuQmCC)](http://www.conan.io/source/jsoncpp/1.8.0/theirix/ci)
4+
35
[JSON][json-org] is a lightweight data-interchange format. It can represent
46
numbers, strings, ordered sequences of values, and collections of name/value
57
pairs.
@@ -30,12 +32,12 @@ format to store user input files.
3032
## Using JsonCpp in your project
3133

3234
The recommended approach to integrating JsonCpp in your project is to include
33-
the [amalgamated source](#generating-amalgamated-source-and-header) (a single
34-
`.cpp` file and two `.h` files) in your project, and compile and build as you
35+
the [amalgamated source](#generating-amalgamated-source-and-header) (a single
36+
`.cpp` file and two `.h` files) in your project, and compile and build as you
3537
would any other source file. This ensures consistency of compilation flags and
36-
ABI compatibility, issues which arise when building shared or static
38+
ABI compatibility, issues which arise when building shared or static
3739
libraries. See the next section for instructions.
38-
40+
3941
The `include/` should be added to your compiler include path. JsonCpp headers
4042
should be included as follow:
4143

@@ -69,6 +71,43 @@ correct order and defining the macro `JSON_IS_AMALGAMATION` to prevent inclusion
6971

7072
## Contributing to JsonCpp
7173

74+
### Building and testing with Conan
75+
76+
[Conan](https://www.conan.io/#/) is an open source package manager intended for C/C++ projects.
77+
It is cross platform and build system agnostic.
78+
79+
Conan requires Python for running, and can be installed using pip:
80+
81+
pip install conan
82+
83+
Detailed instructions can be found on [conan docs](http://docs.conan.io/en/latest/).
84+
85+
For build jsoncpp with conan, you need to create a [conanfile.txt](http://docs.conan.io/en/latest/reference/conanfile_txt.html) or a [conanfile.py](http://docs.conan.io/en/latest/reference/conanfile.html). The first is simpler, but the second is more flexible.
86+
87+
This is a sample conanfile.txt:
88+
89+
```
90+
[requires]
91+
jsoncpp/1.8.0@theirix/ci
92+
93+
[generators]
94+
cmake
95+
```
96+
97+
**Note**: cmake is not required, you can use other [integrations](http://docs.conan.io/en/latest/integrations.html). Or you can set the appropriate environment variables, using [virtualenv generators](http://docs.conan.io/en/latest/mastering/virtualenv.html).
98+
99+
Then run the following command from the conanfile directory:
100+
101+
conan install --build missing
102+
103+
This will try to download the appropriate package for your settings (OS, compiler, architecture) from the [recipe packages](https://www.conan.io/source/jsoncpp/1.8.0/theirix/ci). If it is not found, the package will be built.
104+
105+
**Note**: you do not need to install cmake to build jsoncpp using conan, because the recipe will download it automatically.
106+
107+
If you need, you can customize the jsoncpp recipe. Just clone/fork [it from github](https://github.com/theirix/conan-jsoncpp/).
108+
109+
See [integrations instructions](http://docs.conan.io/en/latest/integrations.html) for how to use your build system with conan.
110+
72111
### Building and testing with CMake
73112

74113
[CMake][] is a C++ Makefiles/Solution generator. It is usually available on most Linux system as package. On Ubuntu:
@@ -85,7 +124,7 @@ When running CMake, a few parameters are required:
85124
* A build directory where the makefiles/solution are generated. It is also used
86125
to store objects, libraries and executables files.
87126
* The generator to use: makefiles or Visual Studio solution? What version or
88-
Visual Studio, 32 or 64 bits solution?
127+
Visual Studio, 32 or 64 bits solution?
89128

90129
Steps for generating solution/makefiles using `cmake-gui`:
91130

@@ -154,17 +193,17 @@ In the instructions below, replace `path/to/jsontest` with the path of the
154193
cd test
155194
# This will run the Reader/Writer tests
156195
python runjsontests.py path/to/jsontest
157-
196+
158197
# This will run the Reader/Writer tests, using JSONChecker test suite
159198
# (http://www.json.org/JSON_checker/).
160199
# Notes: not all tests pass: JsonCpp is too lenient (for example,
161200
# it allows an integer to start with '0'). The goal is to improve
162201
# strict mode parsing to get all tests to pass.
163202
python runjsontests.py --with-json-checker path/to/jsontest
164-
203+
165204
# This will run the unit tests (mostly Value)
166205
python rununittests.py path/to/test_lib_json
167-
206+
168207
# You can run the tests using valgrind:
169208
python rununittests.py --valgrind path/to/test_lib_json
170209

0 commit comments

Comments
 (0)