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 10 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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.13"/>
  7. <meta name="viewport" content="width=device-width, initial-scale=1"/>
  8. <title>json-c: `json-c`</title>
  9. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  10. <script type="text/javascript" src="jquery.js"></script>
  11. <script type="text/javascript" src="dynsections.js"></script>
  12. <link href="doxygen.css" rel="stylesheet" type="text/css" />
  13. </head>
  14. <body>
  15. <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
  16. <div id="titlearea">
  17. <table cellspacing="0" cellpadding="0">
  18. <tbody>
  19. <tr style="height: 56px;">
  20. <td id="projectalign" style="padding-left: 0.5em;">
  21. <div id="projectname">json-c
  22. &#160;<span id="projectnumber">0.13</span>
  23. </div>
  24. </td>
  25. </tr>
  26. </tbody>
  27. </table>
  28. </div>
  29. <!-- end header part -->
  30. <!-- Generated by Doxygen 1.8.13 -->
  31. <script type="text/javascript" src="menudata.js"></script>
  32. <script type="text/javascript" src="menu.js"></script>
  33. <script type="text/javascript">
  34. $(function() {
  35. initMenu('',false,false,'search.php','Search');
  36. });
  37. </script>
  38. <div id="main-nav"></div>
  39. </div><!-- top -->
  40. <div class="header">
  41. <div class="headertitle">
  42. <div class="title">`json-c` </div> </div>
  43. </div><!--header-->
  44. <div class="contents">
  45. <div class="textblock"><ol type="1">
  46. <li><a href="#overview">Overview and Build Status</a></li>
  47. <li><a href="#buildunix">Building on Unix</a></li>
  48. <li><a href="#installprereq">Install Prerequisites</a></li>
  49. <li><a href="#buildthreaded">Building with partial threading support</a></li>
  50. <li><a href="#linking">Linking to libjson-c</a></li>
  51. <li><a href="#using">Using json-c</a></li>
  52. </ol>
  53. <h2>JSON-C - A JSON implementation in C <a class="anchor" id="overview"></a> </h2>
  54. <p>Build Status</p><ul>
  55. <li><a href="https://ci.appveyor.com/project/hawicz/json-c">AppVeyor Build</a> <div class="image">
  56. <img src="https://ci.appveyor.com/api/projects/status/github/json-c/json-c?branch=master&svg=true" alt="AppVeyor Build Status"/>
  57. </div>
  58. </li>
  59. <li><a href="https://travis-ci.org/json-c/json-c">Travis Build</a> <div class="image">
  60. <img src="https://travis-ci.org/json-c/json-c.svg?branch=master" alt="Travis Build Status"/>
  61. </div>
  62. </li>
  63. </ul>
  64. <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>
  65. <h2>Building on Unix with <code>git</code>, <code>gcc</code> and <code>autotools</code> <a class="anchor" id="buildunix"></a> </h2>
  66. <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>
  67. <h3>Prerequisites:</h3>
  68. <p>See also the "Installing prerequisites" section below.</p>
  69. <ul>
  70. <li><code>gcc</code>, <code>clang</code>, or another C compiler</li>
  71. <li><code>libtool&gt;=2.2.6b</code></li>
  72. </ul>
  73. <p>If you're not using a release tarball, you'll also need:</p>
  74. <ul>
  75. <li><code>autoconf&gt;=2.64</code> (<code>autoreconf</code>)</li>
  76. <li><code>automake&gt;=1.13</code></li>
  77. </ul>
  78. <p>Make sure you have a complete <code>libtool</code> install, including <code>libtoolize</code>.</p>
  79. <p>To generate docs (e.g. as part of make distcheck) you'll also need:</p><ul>
  80. <li><code>doxygen&gt;=1.8.13</code></li>
  81. </ul>
  82. <h3>Build instructions:</h3>
  83. <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>
  84. <div class="fragment"><div class="line">$ git clone https://github.com/json-c/json-c.git</div><div class="line">$ cd json-c</div><div class="line">$ sh autogen.sh</div></div><!-- fragment --><p>followed by</p>
  85. <div class="fragment"><div class="line">$ ./configure # --enable-threading</div><div class="line">$ make</div><div class="line">$ make install</div></div><!-- fragment --><p>To build and run the test programs:</p>
  86. <div class="fragment"><div class="line">$ make check</div><div class="line">$ make USE_VALGRIND=0 check # optionally skip using valgrind</div></div><!-- fragment --><h2>Install prerequisites <a class="anchor" id="installprereq"></a> </h2>
  87. <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>
  88. <p>### Install using apt (e.g. Ubuntu 16.04.2 LTS) </p><div class="fragment"><div class="line">sudo apt install git</div><div class="line">sudo apt install autoconf automake libtool</div><div class="line">sudo apt install valgrind # optional</div></div><!-- fragment --><p>Then start from the "git clone" command, above.</p>
  89. <h3>Manually install and build autoconf, automake and libtool</h3>
  90. <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>
  91. <div class="fragment"><div class="line">curl -O http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz</div><div class="line">curl -O http://ftp.gnu.org/gnu/automake/automake-1.15.tar.gz</div><div class="line">curl -O http://ftp.gnu.org/gnu/libtool/libtool-2.2.6b.tar.gz</div><div class="line"></div><div class="line">tar xzf autoconf-2.69.tar.gz</div><div class="line">tar xzf automake-1.15.tar.gz</div><div class="line">tar xzf libtool-2.2.6b.tar.gz</div><div class="line"></div><div class="line">export PATH=${HOME}/ac_install/bin:$PATH</div><div class="line"></div><div class="line">(cd autoconf-2.69 &amp;&amp; \</div><div class="line"> ./configure --prefix ${HOME}/ac_install &amp;&amp; \</div><div class="line"> make &amp;&amp; \</div><div class="line"> make install)</div><div class="line"></div><div class="line">(cd automake-1.15 &amp;&amp; \</div><div class="line"> ./configure --prefix ${HOME}/ac_install &amp;&amp; \</div><div class="line"> make &amp;&amp; \</div><div class="line"> make install)</div><div class="line"></div><div class="line">(cd libtool-2.2.6b &amp;&amp; \</div><div class="line"> ./configure --prefix ${HOME}/ac_install &amp;&amp; \</div><div class="line"> make &amp;&amp; \</div><div class="line"> make install)</div></div><!-- fragment --><h2>Building with partial threading support <a class="anchor" id="buildthreaded"></a> </h2>
  92. <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>
  93. <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>
  94. <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>
  95. <h2>Linking to <code>libjson-c</code> <a class="anchor" id="linking"></a> </h2>
  96. <p>If your system has <code>pkgconfig</code>, then you can just add this to your <code>makefile</code>:</p>
  97. <div class="fragment"><div class="line">CFLAGS += $(shell pkg-config --cflags json-c)</div><div class="line">LDFLAGS += $(shell pkg-config --libs json-c)</div></div><!-- fragment --><p>Without <code>pkgconfig</code>, you would do something like this:</p>
  98. <div class="fragment"><div class="line">JSON_C_DIR=/path/to/json_c/install</div><div class="line">CFLAGS += -I$(JSON_C_DIR)/include/json-c</div><div class="line">LDFLAGS+= -L$(JSON_C_DIR)/lib -ljson-c</div></div><!-- fragment --><h2>Using json-c <a class="anchor" id="using"></a> </h2>
  99. <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>
  100. <ul>
  101. <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>
  102. <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>
  103. <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>
  104. <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>
  105. <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>
  106. <li><a class="el" href="json__util_8h.html" title="Miscllaneous utility functions and macros. ">json_util.h</a> - Miscelleanous utility functions.</li>
  107. </ul>
  108. <p>For a full list of headers see <a href="files.html">files.html</a> </p>
  109. </div></div><!-- contents -->
  110. <!-- start footer part -->
  111. <hr class="footer"/><address class="footer"><small>
  112. Generated on Thu Dec 7 2017 18:06:04 for json-c by &#160;<a href="http://www.doxygen.org/index.html">
  113. <img class="footer" src="doxygen.png" alt="doxygen"/>
  114. </a> 1.8.13
  115. </small></address>
  116. </body>
  117. </html>

No Description