|
Name |
|
Date |
Size |
#Lines |
LOC |
| .. | | 16-Dec-2021 | - |
| autoconf-archive/m4/ | H | 03-May-2022 | - | 19,199 | 17,847 |
| cmake/ | H | 03-May-2021 | - | 205 | 137 |
| fuzz/ | H | 03-May-2021 | - | 71 | 44 |
| tests/ | H | 03-May-2022 | - | 6,089 | 5,000 |
| .editorconfig | H A D | 03-May-2021 | 260 | 16 | 12 |
| .gitignore | H A D | 03-May-2021 | 1.4 KiB | 117 | 110 |
| .travis.yml | H A D | 03-May-2021 | 2.5 KiB | 117 | 106 |
| AUTHORS | H A D | 03-May-2021 | 165 | 6 | 4 |
| Android.configure.mk | H A D | 03-May-2021 | 1.5 KiB | 50 | 30 |
| COPYING | H A D | 03-May-2021 | 2.2 KiB | 43 | 33 |
| ChangeLog | H A D | 03-May-2021 | 16.3 KiB | 397 | 337 |
| Doxyfile | H A D | 03-May-2021 | 100.4 KiB | 2,354 | 1,817 |
| INSTALL | H A D | 03-May-2021 | 47 | 4 | 1 |
| Makefile.am | H A D | 03-May-2021 | 2.7 KiB | 132 | 111 |
| Makefile.in | H A D | 16-Dec-2021 | 38.5 KiB | 1,149 | 1,022 |
| NEWS | H A D | 03-May-2021 | 18 | 2 | 1 |
| README | H A D | 03-May-2021 | 29 | 2 | 1 |
| README.md | H A D | 03-May-2021 | 7.2 KiB | 248 | 181 |
| aclocal.m4 | H A D | 16-Dec-2021 | 41.5 KiB | 1,160 | 1,054 |
| appveyor.yml | H A D | 03-May-2021 | 808 | 38 | 27 |
| arraylist.c | H A D | 03-May-2021 | 3.4 KiB | 147 | 116 |
| arraylist.h | H A D | 03-May-2021 | 1.5 KiB | 71 | 38 |
| autogen.sh | H A D | 03-May-2021 | 276 | 14 | 9 |
| cmake-configure | H A D | 03-May-2021 | 1.8 KiB | 88 | 74 |
| compile | H A D | 16-Dec-2021 | 7.2 KiB | 348 | 258 |
| config.guess | H A D | 16-Dec-2021 | 41.9 KiB | 1,422 | 1,230 |
| config.h.in | H A D | 16-Dec-2021 | 4.8 KiB | 193 | 130 |
| config.h.win32 | H A D | 03-May-2021 | 5.7 KiB | 206 | 149 |
| config.sub | H A D | 16-Dec-2021 | 35.1 KiB | 1,808 | 1,670 |
| configure | H A D | 16-Dec-2021 | 484.9 KiB | 17,139 | 13,855 |
| configure.ac | H A D | 03-May-2021 | 6.3 KiB | 224 | 187 |
| debug.c | H A D | 03-May-2021 | 1.2 KiB | 69 | 46 |
| debug.h | H A D | 03-May-2021 | 1.8 KiB | 84 | 51 |
| depcomp | H A D | 16-Dec-2021 | 23 KiB | 792 | 502 |
| install-sh | H A D | 16-Dec-2021 | 14.3 KiB | 502 | 327 |
| issues_closed_for_0.13.md | H A D | 03-May-2021 | 25.3 KiB | 268 | 261 |
| json-c-uninstalled.pc.in | H A D | 03-May-2021 | 218 | 12 | 10 |
| json-c.pc.in | H A D | 03-May-2021 | 260 | 13 | 11 |
| json.h | H A D | 03-May-2021 | 810 | 39 | 18 |
| json_c_version.c | H A D | 03-May-2021 | 364 | 21 | 10 |
| json_c_version.h | H A D | 03-May-2021 | 1.3 KiB | 49 | 19 |
| json_config.h.in | H A D | 03-May-2021 | 91 | 4 | 2 |
| json_config.h.win32 | H A D | 03-May-2021 | 143 | 6 | 4 |
| json_inttypes.h | H A D | 03-May-2021 | 350 | 24 | 11 |
| json_object.c | H A D | 03-May-2021 | 37.4 KiB | 1,531 | 1,219 |
| json_object.h | H A D | 03-May-2021 | 37.6 KiB | 1,042 | 175 |
| json_object_iterator.c | H A D | 03-May-2021 | 4.5 KiB | 164 | 60 |
| json_object_iterator.h | H A D | 03-May-2021 | 8.3 KiB | 249 | 37 |
| json_object_private.h | H A D | 03-May-2021 | 1.5 KiB | 65 | 38 |
| json_pointer.c | H A D | 03-May-2021 | 6.6 KiB | 328 | 243 |
| json_pointer.h | H A D | 03-May-2021 | 4.8 KiB | 121 | 14 |
| json_tokener.c | H A D | 03-May-2021 | 29.9 KiB | 1,038 | 853 |
| json_tokener.h | H A D | 03-May-2021 | 8.3 KiB | 264 | 92 |
| json_util.c | H A D | 03-May-2021 | 6 KiB | 268 | 208 |
| json_util.h | H A D | 03-May-2021 | 3.4 KiB | 119 | 27 |
| json_visit.c | H A D | 03-May-2021 | 3.9 KiB | 134 | 110 |
| json_visit.h | H A D | 03-May-2021 | 3.1 KiB | 96 | 15 |
| libjson.c | H A D | 03-May-2021 | 624 | 27 | 13 |
| linkhash.c | H A D | 03-May-2021 | 20.8 KiB | 679 | 430 |
| linkhash.h | H A D | 03-May-2021 | 10 KiB | 382 | 78 |
| ltmain.sh | H A D | 16-Dec-2021 | 316.5 KiB | 11,148 | 7,979 |
| math_compat.h | H A D | 03-May-2021 | 644 | 37 | 24 |
| missing | H A D | 16-Dec-2021 | 6.7 KiB | 216 | 143 |
| printbuf.c | H A D | 03-May-2021 | 3.5 KiB | 156 | 108 |
| printbuf.h | H A D | 03-May-2021 | 3.9 KiB | 131 | 46 |
| random_seed.c | H A D | 03-May-2021 | 4.5 KiB | 241 | 155 |
| random_seed.h | H A D | 03-May-2021 | 506 | 30 | 10 |
| snprintf_compat.h | H A D | 03-May-2021 | 943 | 42 | 26 |
| strdup_compat.h | H A D | 03-May-2021 | 367 | 17 | 8 |
| strerror_override.c | H A D | 03-May-2021 | 1.9 KiB | 101 | 81 |
| strerror_override.h | H A D | 03-May-2021 | 510 | 31 | 17 |
| strerror_override_private.h | H A D | 03-May-2021 | 281 | 13 | 4 |
| test-driver | H A D | 16-Dec-2021 | 4.5 KiB | 149 | 87 |
| vasprintf_compat.h | H A D | 03-May-2021 | 1 KiB | 48 | 31 |
README
README.md
1`json-c`
2========
3
41. [Overview and Build Status](#overview)
52. [Building on Unix](#buildunix)
63. [Install Prerequisites](#installprereq)
74. [Building with partial threading support](#buildthreaded)
85. [Building with CMake](#CMake)
96. [Linking to libjson-c](#linking)
107. [Using json-c](#using)
11
12JSON-C - A JSON implementation in C <a name="overview"></a>
13-----------------------------------
14
15Build Status
16* [AppVeyor Build](https://ci.appveyor.com/project/hawicz/json-c) ![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/json-c/json-c?branch=master&svg=true)
17* [Travis Build](https://travis-ci.org/json-c/json-c) ![Travis Build Status](https://travis-ci.org/json-c/json-c.svg?branch=master)
18
19JSON-C implements a reference counting object model that allows you to easily
20construct JSON objects in C, output them as JSON formatted strings and parse
21JSON formatted strings back into the C representation of JSON objects.
22It aims to conform to [RFC 7159](https://tools.ietf.org/html/rfc7159).
23
24Building on Unix and Windows with `vcpkg`, `gcc`/`g++`, `curl`, `unzip`, and `tar`
25--------------------------------------------------
26
27You can download and install JSON-C using the [vcpkg](https://github.com/Microsoft/vcpkg/) dependency manager:
28
29 git clone https://github.com/Microsoft/vcpkg.git
30 cd vcpkg
31 ./bootstrap-vcpkg.sh
32 ./vcpkg integrate install
33 vcpkg install json-c
34
35The JSON-C port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
36
37Building on Unix with `git`, `gcc` and `autotools` <a name="buildunix"></a>
38--------------------------------------------------
39
40Home page for json-c: https://github.com/json-c/json-c/wiki
41
42### Prerequisites:
43
44See also the "Installing prerequisites" section below.
45
46 - `gcc`, `clang`, or another C compiler
47 - `libtool>=2.2.6b`
48
49If you're not using a release tarball, you'll also need:
50
51 - `autoconf>=2.64` (`autoreconf`)
52 - `automake>=1.13`
53
54Make sure you have a complete `libtool` install, including `libtoolize`.
55
56To generate docs (e.g. as part of make distcheck) you'll also need:
57 - `doxygen>=1.8.13`
58
59### Build instructions:
60
61`json-c` GitHub repo: https://github.com/json-c/json-c
62
63```sh
64$ git clone https://github.com/json-c/json-c.git
65$ cd json-c
66$ sh autogen.sh
67```
68
69followed by
70
71```sh
72$ ./configure # --enable-threading
73$ make
74$ make install
75```
76
77To build and run the test programs:
78
79```sh
80$ make check
81$ make USE_VALGRIND=0 check # optionally skip using valgrind
82```
83
84Install prerequisites <a name="installprereq"></a>
85-----------------------
86
87If you are on a relatively modern system, you'll likely be able to install
88the prerequisites using your OS's packaging system.
89
90### Install using apt (e.g. Ubuntu 16.04.2 LTS)
91```sh
92sudo apt install git
93sudo apt install autoconf automake libtool
94sudo apt install valgrind # optional
95```
96
97Then start from the "git clone" command, above.
98
99### Manually install and build autoconf, automake and libtool
100
101For older OS's that don't have up-to-date versions of the packages will
102require a bit more work. For example, CentOS release 5.11, etc...
103
104```sh
105curl -O http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
106curl -O http://ftp.gnu.org/gnu/automake/automake-1.15.tar.gz
107curl -O http://ftp.gnu.org/gnu/libtool/libtool-2.2.6b.tar.gz
108
109tar xzf autoconf-2.69.tar.gz
110tar xzf automake-1.15.tar.gz
111tar xzf libtool-2.2.6b.tar.gz
112
113export PATH=${HOME}/ac_install/bin:$PATH
114
115(cd autoconf-2.69 && \
116 ./configure --prefix ${HOME}/ac_install && \
117 make && \
118 make install)
119
120(cd automake-1.15 && \
121 ./configure --prefix ${HOME}/ac_install && \
122 make && \
123 make install)
124
125(cd libtool-2.2.6b && \
126 ./configure --prefix ${HOME}/ac_install && \
127 make && \
128 make install)
129```
130
131
132Building with partial threading support <a name="buildthreaded"></a>
133----------------------------------------
134
135Although json-c does not support fully multi-threaded access to
136object trees, it has some code to help make its use in threaded programs
137a bit safer. Currently, this is limited to using atomic operations for
138json_object_get() and json_object_put().
139
140Since this may have a performance impact, of at least 3x slower
141according to https://stackoverflow.com/a/11609063, it is disabled by
142default. You may turn it on by adjusting your configure command with:
143 --enable-threading
144
145Separately, the default hash function used for object field keys,
146lh_char_hash, uses a compare-and-swap operation to ensure the random
147seed is only generated once. Because this is a one-time operation, it
148is always compiled in when the compare-and-swap operation is available.
149
150Building with CMake <a name="CMake"></a>
151--------------------
152
153To use [CMake](https://cmake.org/cmake-tutorial/), build it like:
154
155```sh
156mkdir build
157cd build
158cmake ../
159make
160```
161
162CMake can take a few options.
163
164Variable | Type | Description
165---------------------|--------|--------------
166CMAKE_INSTALL_PREFIX | String | The install location.
167BUILD_SHARED_LIBS | Bool | The default build generates a dynamic (dll/so) library. Set this to OFF to create a static library instead.
168ENABLE_RDRAND | Bool | Enable RDRAND Hardware RNG Hash Seed
169ENABLE_THREADING | Bool | Enable partial threading support
170
171Pass these options as `-D` on CMake's command-line.
172
173```sh
174cmake -DBUILD_SHARED_LIBS=OFF ...
175```
176
177Testing with cmake:
178
179By default, if valgrind is available running tests uses it.
180That can slow the tests down considerably, so to disable it use:
181```sh
182export USE_VALGRIND=0
183```
184
185To run tests:
186```sh
187mkdir build-test
188cd build-test
189# VALGRIND=1 causes -DVALGRIND=1 to be included when building
190VALGRIND=1 cmake ..
191make
192
193make test
194# By default, if valgrind is available running tests uses it.
195make USE_VALGRIND=0 test # optionally skip using valgrind
196```
197
198If a test fails, check `Testing/Temporary/LastTest.log`,
199`tests/testSubDir/${testname}/${testname}.vg.out`, and other similar files.
200If there is insufficient output try:
201```sh
202VERBOSE=1 make test
203```
204or
205```sh
206JSONC_TEST_TRACE=1 make test
207```
208and check the log files again.
209
210
211
212Linking to `libjson-c` <a name="linking">
213----------------------
214
215If your system has `pkgconfig`,
216then you can just add this to your `makefile`:
217
218```make
219CFLAGS += $(shell pkg-config --cflags json-c)
220LDFLAGS += $(shell pkg-config --libs json-c)
221```
222
223Without `pkgconfig`, you would do something like this:
224
225```make
226JSON_C_DIR=/path/to/json_c/install
227CFLAGS += -I$(JSON_C_DIR)/include/json-c
228LDFLAGS+= -L$(JSON_C_DIR)/lib -ljson-c
229```
230
231
232Using json-c <a name="using">
233------------
234
235To use json-c you can either include json.h, or preferrably, one of the
236following more specific header files:
237
238* json_object.h - Core types and methods.
239* json_tokener.h - Methods for parsing and serializing json-c object trees.
240* json_pointer.h - JSON Pointer (RFC 6901) implementation for retrieving
241 objects from a json-c object tree.
242* json_object_iterator.h - Methods for iterating over single json_object instances.
243* json_visit.h - Methods for walking a tree of json-c objects.
244* json_util.h - Miscelleanous utility functions.
245
246For a full list of headers see [files.html](http://json-c.github.io/json-c/json-c-0.13.1/doc/html/files.html)
247
248