|
16 | 16 | JSON-C - A JSON implementation in C <a name="overview"></a>
|
17 | 17 | -----------------------------------
|
18 | 18 |
|
| 19 | +JSON-C implements a reference counting object model that allows you to easily |
| 20 | +construct JSON objects in C, output them as JSON formatted strings and parse |
| 21 | +JSON formatted strings back into the C representation of JSON objects. |
| 22 | +It aims to conform to [RFC 7159](https://tools.ietf.org/html/rfc7159). |
| 23 | + |
| 24 | +Skip down to [Using json-c](#using) |
| 25 | +or check out the [API docs](https://json-c.github.io/json-c/), |
| 26 | +if you already have json-c installed and ready to use. |
| 27 | + |
| 28 | +Home page for json-c: https://github.com/json-c/json-c/wiki |
| 29 | + |
19 | 30 | Build Status
|
20 | 31 | * [AppVeyor Build](https://ci.appveyor.com/project/hawicz/json-c) 
|
21 | 32 | * [Travis Build](https://travis-ci.org/json-c/json-c) 
|
22 | 33 |
|
23 | 34 | Test Status
|
24 | 35 | * [Coveralls](https://coveralls.io/github/json-c/json-c?branch=master) [](https://coveralls.io/github/json-c/json-c?branch=master)
|
25 | 36 |
|
26 |
| -JSON-C implements a reference counting object model that allows you to easily |
27 |
| -construct JSON objects in C, output them as JSON formatted strings and parse |
28 |
| -JSON formatted strings back into the C representation of JSON objects. |
29 |
| -It aims to conform to [RFC 7159](https://tools.ietf.org/html/rfc7159). |
30 |
| - |
31 | 37 | Building on Unix with `git`, `gcc` and `cmake` <a name="buildunix"></a>
|
32 | 38 | --------------------------------------------------
|
33 | 39 |
|
34 |
| -Home page for json-c: https://github.com/json-c/json-c/wiki |
| 40 | +If you already have json-c installed, see [Linking to `libjson-c`](#linking) |
| 41 | +for how to build and link your program against it. |
35 | 42 |
|
36 | 43 | ### Prerequisites: <a name="installprereq"></a>
|
37 | 44 |
|
@@ -220,14 +227,31 @@ CFLAGS += $(shell pkg-config --cflags json-c)
|
220 | 227 | LDFLAGS += $(shell pkg-config --libs json-c)
|
221 | 228 | ```
|
222 | 229 |
|
223 |
| -Without `pkgconfig`, you would do something like this: |
| 230 | +Without `pkgconfig`, you might do something like this: |
224 | 231 |
|
225 | 232 | ```make
|
226 | 233 | JSON_C_DIR=/path/to/json_c/install
|
227 | 234 | CFLAGS += -I$(JSON_C_DIR)/include/json-c
|
| 235 | +# Or to use lines like: #include <json-c/json_object.h> |
| 236 | +#CFLAGS += -I$(JSON_C_DIR)/include |
228 | 237 | LDFLAGS+= -L$(JSON_C_DIR)/lib -ljson-c
|
229 | 238 | ```
|
230 | 239 |
|
| 240 | +If your project uses cmake: |
| 241 | + |
| 242 | +* Add to your CMakeLists.txt file: |
| 243 | + |
| 244 | +```cmake |
| 245 | +find_package(json-c CONFIG) |
| 246 | +target_link_libraries(${PROJECT_NAME} PRIVATE json-c::json-c) |
| 247 | +``` |
| 248 | + |
| 249 | +* Then you might run in your project: |
| 250 | + |
| 251 | +```sh |
| 252 | +cd build |
| 253 | +cmake -DCMAKE_PREFIX_PATH=/path/to/json_c/install/lib64/cmake .. |
| 254 | +``` |
231 | 255 |
|
232 | 256 | Using json-c <a name="using">
|
233 | 257 | ------------
|
|
0 commit comments