• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..16-Dec-2021-

autoconf-archive/m4/H03-May-2022-19,19917,847

cmake/H03-May-2021-205137

fuzz/H03-May-2021-7144

tests/H03-May-2022-6,0895,000

.editorconfigH A D03-May-2021260 1612

.gitignoreH A D03-May-20211.4 KiB117110

.travis.ymlH A D03-May-20212.5 KiB117106

AUTHORSH A D03-May-2021165 64

Android.configure.mkH A D03-May-20211.5 KiB5030

COPYINGH A D03-May-20212.2 KiB4333

ChangeLogH A D03-May-202116.3 KiB397337

DoxyfileH A D03-May-2021100.4 KiB2,3541,817

INSTALLH A D03-May-202147 41

Makefile.amH A D03-May-20212.7 KiB132111

Makefile.inH A D16-Dec-202138.5 KiB1,1491,022

NEWSH A D03-May-202118 21

READMEH A D03-May-202129 21

README.mdH A D03-May-20217.2 KiB248181

aclocal.m4H A D16-Dec-202141.5 KiB1,1601,054

appveyor.ymlH A D03-May-2021808 3827

arraylist.cH A D03-May-20213.4 KiB147116

arraylist.hH A D03-May-20211.5 KiB7138

autogen.shH A D03-May-2021276 149

cmake-configureH A D03-May-20211.8 KiB8874

compileH A D16-Dec-20217.2 KiB348258

config.guessH A D16-Dec-202141.9 KiB1,4221,230

config.h.inH A D16-Dec-20214.8 KiB193130

config.h.win32H A D03-May-20215.7 KiB206149

config.subH A D16-Dec-202135.1 KiB1,8081,670

configureH A D16-Dec-2021484.9 KiB17,13913,855

configure.acH A D03-May-20216.3 KiB224187

debug.cH A D03-May-20211.2 KiB6946

debug.hH A D03-May-20211.8 KiB8451

depcompH A D16-Dec-202123 KiB792502

install-shH A D16-Dec-202114.3 KiB502327

issues_closed_for_0.13.mdH A D03-May-202125.3 KiB268261

json-c-uninstalled.pc.inH A D03-May-2021218 1210

json-c.pc.inH A D03-May-2021260 1311

json.hH A D03-May-2021810 3918

json_c_version.cH A D03-May-2021364 2110

json_c_version.hH A D03-May-20211.3 KiB4919

json_config.h.inH A D03-May-202191 42

json_config.h.win32H A D03-May-2021143 64

json_inttypes.hH A D03-May-2021350 2411

json_object.cH A D03-May-202137.4 KiB1,5311,219

json_object.hH A D03-May-202137.6 KiB1,042175

json_object_iterator.cH A D03-May-20214.5 KiB16460

json_object_iterator.hH A D03-May-20218.3 KiB24937

json_object_private.hH A D03-May-20211.5 KiB6538

json_pointer.cH A D03-May-20216.6 KiB328243

json_pointer.hH A D03-May-20214.8 KiB12114

json_tokener.cH A D03-May-202129.9 KiB1,038853

json_tokener.hH A D03-May-20218.3 KiB26492

json_util.cH A D03-May-20216 KiB268208

json_util.hH A D03-May-20213.4 KiB11927

json_visit.cH A D03-May-20213.9 KiB134110

json_visit.hH A D03-May-20213.1 KiB9615

libjson.cH A D03-May-2021624 2713

linkhash.cH A D03-May-202120.8 KiB679430

linkhash.hH A D03-May-202110 KiB38278

ltmain.shH A D16-Dec-2021316.5 KiB11,1487,979

math_compat.hH A D03-May-2021644 3724

missingH A D16-Dec-20216.7 KiB216143

printbuf.cH A D03-May-20213.5 KiB156108

printbuf.hH A D03-May-20213.9 KiB13146

random_seed.cH A D03-May-20214.5 KiB241155

random_seed.hH A D03-May-2021506 3010

snprintf_compat.hH A D03-May-2021943 4226

strdup_compat.hH A D03-May-2021367 178

strerror_override.cH A D03-May-20211.9 KiB10181

strerror_override.hH A D03-May-2021510 3117

strerror_override_private.hH A D03-May-2021281 134

test-driverH A D16-Dec-20214.5 KiB14987

vasprintf_compat.hH A D03-May-20211 KiB4831

README

1See README.md or README.html
2

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