You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.html 9.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  5. <meta http-equiv="X-UA-Compatible" content="IE=9"/>
  6. <meta name="generator" content="Doxygen 1.8.8"/>
  7. <title>json-c: `json-c`</title>
  8. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  9. <script type="text/javascript" src="jquery.js"></script>
  10. <script type="text/javascript" src="dynsections.js"></script>
  11. <link href="doxygen.css" rel="stylesheet" type="text/css" />
  12. </head>
  13. <body>
  14. <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
  15. <div id="titlearea">
  16. <table cellspacing="0" cellpadding="0">
  17. <tbody>
  18. <tr style="height: 56px;">
  19. <td style="padding-left: 0.5em;">
  20. <div id="projectname">json-c
  21. &#160;<span id="projectnumber">0.13.1</span>
  22. </div>
  23. </td>
  24. </tr>
  25. </tbody>
  26. </table>
  27. </div>
  28. <!-- end header part -->
  29. <!-- Generated by Doxygen 1.8.8 -->
  30. <div id="navrow1" class="tabs">
  31. <ul class="tablist">
  32. <li class="current"><a href="index.html"><span>Main&#160;Page</span></a></li>
  33. <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
  34. <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
  35. <li><a href="files.html"><span>Files</span></a></li>
  36. </ul>
  37. </div>
  38. </div><!-- top -->
  39. <div class="header">
  40. <div class="headertitle">
  41. <div class="title">`json-c` </div> </div>
  42. </div><!--header-->
  43. <div class="contents">
  44. <div class="textblock"><ol type="1">
  45. <li><a href="#overview">Overview and Build Status</a></li>
  46. <li><a href="#buildunix">Building on Unix</a></li>
  47. <li><a href="#installprereq">Install Prerequisites</a></li>
  48. <li><a href="#buildthreaded">Building with partial threading support</a></li>
  49. <li><a href="#linking">Linking to libjson-c</a></li>
  50. <li><a href="#using">Using json-c</a></li>
  51. </ol>
  52. <h2>JSON-C - A JSON implementation in C <a class="anchor" id="overview"></a> </h2>
  53. <p>Build Status</p><ul>
  54. <li><a href="https://ci.appveyor.com/project/hawicz/json-c">AppVeyor Build</a> <div class="image">
  55. <img src="https://ci.appveyor.com/api/projects/status/github/json-c/json-c?branch=master&svg=true" alt="AppVeyor Build Status"/>
  56. </div>
  57. </li>
  58. <li><a href="https://travis-ci.org/json-c/json-c">Travis Build</a> <div class="image">
  59. <img src="https://travis-ci.org/json-c/json-c.svg?branch=master" alt="Travis Build Status"/>
  60. </div>
  61. </li>
  62. </ul>
  63. <p>JSON-C implements a reference counting object model that allows you to easily construct JSON objects in C, output them as JSON formatted strings and parse JSON formatted strings back into the C representation of JSON objects. It aims to conform to <a href="https://tools.ietf.org/html/rfc7159">RFC 7159</a>.</p>
  64. <h2>Building on Unix with <code>git</code>, <code>gcc</code> and <code>autotools</code> <a class="anchor" id="buildunix"></a> </h2>
  65. <p>Home page for json-c: <a href="https://github.com/json-c/json-c/wiki">https://github.com/json-c/json-c/wiki</a></p>
  66. <h3>Prerequisites:</h3>
  67. <p>See also the "Installing prerequisites" section below.</p>
  68. <ul>
  69. <li><code>gcc</code>, <code>clang</code>, or another C compiler</li>
  70. <li><code>libtool&gt;=2.2.6b</code></li>
  71. </ul>
  72. <p>If you're not using a release tarball, you'll also need:</p>
  73. <ul>
  74. <li><code>autoconf&gt;=2.64</code> (<code>autoreconf</code>)</li>
  75. <li><code>automake&gt;=1.13</code></li>
  76. </ul>
  77. <p>Make sure you have a complete <code>libtool</code> install, including <code>libtoolize</code>.</p>
  78. <p>To generate docs (e.g. as part of make distcheck) you'll also need:</p><ul>
  79. <li><code>doxygen&gt;=1.8.13</code></li>
  80. </ul>
  81. <h3>Build instructions:</h3>
  82. <p><code>json-c</code> GitHub repo: <a href="https://github.com/json-c/json-c">https://github.com/json-c/json-c</a></p>
  83. <p>```sh $ git clone <a href="https://github.com/json-c/json-c.git">https://github.com/json-c/json-c.git</a> $ cd json-c $ sh autogen.sh ```</p>
  84. <p>followed by</p>
  85. <p>```sh $ ./configure # &ndash;enable-threading $ make $ make install ```</p>
  86. <p>To build and run the test programs:</p>
  87. <p>```sh $ make check $ make USE_VALGRIND=0 check # optionally skip using valgrind ```</p>
  88. <h2>Install prerequisites <a class="anchor" id="installprereq"></a> </h2>
  89. <p>If you are on a relatively modern system, you'll likely be able to install the prerequisites using your OS's packaging system.</p>
  90. <h3>Install using apt (e.g. Ubuntu 16.04.2 LTS)</h3>
  91. <p>```sh sudo apt install git sudo apt install autoconf automake libtool sudo apt install valgrind # optional ```</p>
  92. <p>Then start from the "git clone" command, above.</p>
  93. <h3>Manually install and build autoconf, automake and libtool</h3>
  94. <p>For older OS's that don't have up-to-date version of the packages will require a bit more work. For example, CentOS release 5.11, etc...</p>
  95. <p>```sh curl -O <a href="http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz">http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz</a> curl -O <a href="http://ftp.gnu.org/gnu/automake/automake-1.15.tar.gz">http://ftp.gnu.org/gnu/automake/automake-1.15.tar.gz</a> curl -O <a href="http://ftp.gnu.org/gnu/libtool/libtool-2.2.6b.tar.gz">http://ftp.gnu.org/gnu/libtool/libtool-2.2.6b.tar.gz</a></p>
  96. <p>tar xzf autoconf-2.69.tar.gz tar xzf automake-1.15.tar.gz tar xzf libtool-2.2.6b.tar.gz</p>
  97. <p>export PATH=${HOME}/ac_install/bin:$PATH</p>
  98. <p>(cd autoconf-2.69 &amp;&amp; \ ./configure &ndash;prefix ${HOME}/ac_install &amp;&amp; \ make &amp;&amp; \ make install)</p>
  99. <p>(cd automake-1.15 &amp;&amp; \ ./configure &ndash;prefix ${HOME}/ac_install &amp;&amp; \ make &amp;&amp; \ make install)</p>
  100. <p>(cd libtool-2.2.6b &amp;&amp; \ ./configure &ndash;prefix ${HOME}/ac_install &amp;&amp; \ make &amp;&amp; \ make install) ```</p>
  101. <h2>Building with partial threading support <a class="anchor" id="buildthreaded"></a> </h2>
  102. <p>Although json-c does not support fully multi-threaded access to object trees, it has some code to help make use in threaded programs a bit safer. Currently, this is limited to using atomic operations for <a class="el" href="json__object_8h.html#a675aa3a9cced685dbfd1c1a770a0c3e4">json_object_get()</a> and <a class="el" href="json__object_8h.html#afabf61f932cd64a4122ca8092452eed5">json_object_put()</a>.</p>
  103. <p>Since this may have a performance impact, of at least 3x slower according to <a href="https://stackoverflow.com/a/11609063,">https://stackoverflow.com/a/11609063,</a> it is disabled by default. You may turn it on by adjusting your configure command with: &ndash;enable-threading</p>
  104. <p>Separately, the default hash function used for object field keys, lh_char_hash, uses a compare-and-swap operation to ensure the randomly seed is only generated once. Because this is a one-time operation, it is always compiled in when the compare-and-swap operation is available.</p>
  105. <h2>Linking to <code>libjson-c</code> <a class="anchor" id="linking"></a> </h2>
  106. <p>If your system has <code>pkgconfig</code>, then you can just add this to your <code>makefile</code>:</p>
  107. <p>```make CFLAGS += $(shell pkg-config &ndash;cflags json-c) LDFLAGS += $(shell pkg-config &ndash;libs json-c) ```</p>
  108. <p>Without <code>pkgconfig</code>, you would do something like this:</p>
  109. <p>```make JSON_C_DIR=/path/to/json_c/install CFLAGS += -I/include/json-c LDFLAGS+= -L/lib -ljson-c ```</p>
  110. <h2>Using json-c <a class="anchor" id="using"></a> </h2>
  111. <p>To use json-c you can either include <a class="el" href="json_8h.html" title="A convenience header that may be included instead of other individual ones. ">json.h</a>, or preferrably, one of the following more specific header files:</p>
  112. <ul>
  113. <li><a class="el" href="json__object_8h.html" title="Core json-c API. Start here, or with json_tokener.h. ">json_object.h</a> - Core types and methods.</li>
  114. <li><a class="el" href="json__tokener_8h.html" title="Methods to parse an input string into a tree of json_object objects. ">json_tokener.h</a> - Methods for parsing and serializing json-c object trees.</li>
  115. <li><a class="el" href="json__pointer_8h.html" title="JSON Pointer (RFC 6901) implementation for retrieving objects from a json-c object tree...">json_pointer.h</a> - JSON Pointer (RFC 6901) implementation for retrieving objects from a json-c object tree.</li>
  116. <li><a class="el" href="json__object__iterator_8h.html" title="An API for iterating over json_type_object objects, styled to be familiar to C++ programmers. Unlike json_object_object_foreach() and json_object_object_foreachC(), this avoids the need to expose json-c internals like lh_entry. ">json_object_iterator.h</a> - Methods for iterating over single <a class="el" href="structjson__object.html">json_object</a> instances.</li>
  117. <li><a class="el" href="json__visit_8h.html" title="Methods for walking a tree of objects. ">json_visit.h</a> - Methods for walking a tree of json-c objects.</li>
  118. <li><a class="el" href="json__util_8h.html" title="Miscllaneous utility functions and macros. ">json_util.h</a> - Miscelleanous utility functions.</li>
  119. </ul>
  120. <p>For a full list of headers see <a href="files.html">files.html</a> </p>
  121. </div></div><!-- contents -->
  122. <!-- start footer part -->
  123. <hr class="footer"/><address class="footer"><small>
  124. Generated on Mon Mar 5 2018 23:17:09 for json-c by &#160;<a href="http://www.doxygen.org/index.html">
  125. <img class="footer" src="doxygen.png" alt="doxygen"/>
  126. </a> 1.8.8
  127. </small></address>
  128. </body>
  129. </html>

No Description

Contributors (1)