• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/json-c/doc/html/json__pointer_8h.html

  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 <title>json-c: /home/erh/json-c-0.15/json_pointer.h File Reference</title>
  7 <link href="tabs.css" rel="stylesheet" type="text/css"/>
  8 <script type="text/javascript" src="jquery.js"></script>
  9 <script type="text/javascript" src="dynsections.js"></script>
 10 <link href="doxygen.css" rel="stylesheet" type="text/css" />
 11 </head>
 12 <body>
 13 <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
 14 <div id="titlearea">
 15 <table cellspacing="0" cellpadding="0">
 16  <tbody>
 17  <tr style="height: 56px;">
 18   <td style="padding-left: 0.5em;">
 19    <div id="projectname">json-c
 20    &#160;<span id="projectnumber">0.15</span>
 21    </div>
 22   </td>
 23  </tr>
 24  </tbody>
 25 </table>
 26 </div>
 27 <!-- end header part -->
 28 <!-- Generated by Doxygen 1.8.2 -->
 29   <div id="navrow1" class="tabs">
 30     <ul class="tablist">
 31       <li><a href="index.html"><span>Main&#160;Page</span></a></li>
 32       <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
 33       <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
 34       <li class="current"><a href="files.html"><span>Files</span></a></li>
 35     </ul>
 36   </div>
 37   <div id="navrow2" class="tabs2">
 38     <ul class="tablist">
 39       <li><a href="files.html"><span>File&#160;List</span></a></li>
 40       <li><a href="globals.html"><span>Globals</span></a></li>
 41     </ul>
 42   </div>
 43 <div id="nav-path" class="navpath">
 44   <ul>
 45 <li class="navelem"><a class="el" href="dir_71f13e590eb9d766c31051438785ada5.html">json-c-0.15</a></li>  </ul>
 46 </div>
 47 </div><!-- top -->
 48 <div class="header">
 49   <div class="summary">
 50 <a href="#func-members">Functions</a>  </div>
 51   <div class="headertitle">
 52 <div class="title">json_pointer.h File Reference</div>  </div>
 53 </div><!--header-->
 54 <div class="contents">
 55 
 56 <p>JSON Pointer (RFC 6901) implementation for retrieving objects from a json-c object tree.  
 57 <a href="#details">More...</a></p>
 58 <table class="memberdecls">
 59 <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
 60 Functions</h2></td></tr>
 61 <tr class="memitem:aff88937e32b0ba6ffbd07cb4b1919053"><td class="memItemLeft" align="right" valign="top"><a class="el" href="printbuf_8h.html#a2a31d5c00f3a4712f2d5d62aee66344e">JSON_EXPORT</a> int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="json__pointer_8h.html#aff88937e32b0ba6ffbd07cb4b1919053">json_pointer_get</a> (struct <a class="el" href="json__types_8h.html#af27907ced0f5a43409ad96430fe0f914">json_object</a> *obj, const char *path, struct <a class="el" href="json__types_8h.html#af27907ced0f5a43409ad96430fe0f914">json_object</a> **res)</td></tr>
 62 <tr class="separator:aff88937e32b0ba6ffbd07cb4b1919053"><td class="memSeparator" colspan="2">&#160;</td></tr>
 63 <tr class="memitem:af0ac03df64b215d05041e8007ed0233d"><td class="memItemLeft" align="right" valign="top"><a class="el" href="printbuf_8h.html#a2a31d5c00f3a4712f2d5d62aee66344e">JSON_EXPORT</a> int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="json__pointer_8h.html#af0ac03df64b215d05041e8007ed0233d">json_pointer_getf</a> (struct <a class="el" href="json__types_8h.html#af27907ced0f5a43409ad96430fe0f914">json_object</a> *obj, struct <a class="el" href="json__types_8h.html#af27907ced0f5a43409ad96430fe0f914">json_object</a> **res, const char *path_fmt,...)</td></tr>
 64 <tr class="separator:af0ac03df64b215d05041e8007ed0233d"><td class="memSeparator" colspan="2">&#160;</td></tr>
 65 <tr class="memitem:aef0e651f63ce5ce35648503705e2586b"><td class="memItemLeft" align="right" valign="top"><a class="el" href="printbuf_8h.html#a2a31d5c00f3a4712f2d5d62aee66344e">JSON_EXPORT</a> int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="json__pointer_8h.html#aef0e651f63ce5ce35648503705e2586b">json_pointer_set</a> (struct <a class="el" href="json__types_8h.html#af27907ced0f5a43409ad96430fe0f914">json_object</a> **obj, const char *path, struct <a class="el" href="json__types_8h.html#af27907ced0f5a43409ad96430fe0f914">json_object</a> *value)</td></tr>
 66 <tr class="separator:aef0e651f63ce5ce35648503705e2586b"><td class="memSeparator" colspan="2">&#160;</td></tr>
 67 <tr class="memitem:a66f1f98a2ce085c19f6750193b4c726d"><td class="memItemLeft" align="right" valign="top"><a class="el" href="printbuf_8h.html#a2a31d5c00f3a4712f2d5d62aee66344e">JSON_EXPORT</a> int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="json__pointer_8h.html#a66f1f98a2ce085c19f6750193b4c726d">json_pointer_setf</a> (struct <a class="el" href="json__types_8h.html#af27907ced0f5a43409ad96430fe0f914">json_object</a> **obj, struct <a class="el" href="json__types_8h.html#af27907ced0f5a43409ad96430fe0f914">json_object</a> *value, const char *path_fmt,...)</td></tr>
 68 <tr class="separator:a66f1f98a2ce085c19f6750193b4c726d"><td class="memSeparator" colspan="2">&#160;</td></tr>
 69 </table>
 70 <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
 71 <div class="textblock"><p>JSON Pointer (RFC 6901) implementation for retrieving objects from a json-c object tree. </p>
 72 </div><h2 class="groupheader">Function Documentation</h2>
 73 <a class="anchor" id="aff88937e32b0ba6ffbd07cb4b1919053"></a>
 74 <div class="memitem">
 75 <div class="memproto">
 76       <table class="memname">
 77         <tr>
 78           <td class="memname"><a class="el" href="printbuf_8h.html#a2a31d5c00f3a4712f2d5d62aee66344e">JSON_EXPORT</a> int json_pointer_get </td>
 79           <td>(</td>
 80           <td class="paramtype">struct <a class="el" href="json__types_8h.html#af27907ced0f5a43409ad96430fe0f914">json_object</a> *&#160;</td>
 81           <td class="paramname"><em>obj</em>, </td>
 82         </tr>
 83         <tr>
 84           <td class="paramkey"></td>
 85           <td></td>
 86           <td class="paramtype">const char *&#160;</td>
 87           <td class="paramname"><em>path</em>, </td>
 88         </tr>
 89         <tr>
 90           <td class="paramkey"></td>
 91           <td></td>
 92           <td class="paramtype">struct <a class="el" href="json__types_8h.html#af27907ced0f5a43409ad96430fe0f914">json_object</a> **&#160;</td>
 93           <td class="paramname"><em>res</em>&#160;</td>
 94         </tr>
 95         <tr>
 96           <td></td>
 97           <td>)</td>
 98           <td></td><td></td>
 99         </tr>
100       </table>
101 </div><div class="memdoc">
102 <p>Retrieves a JSON sub-object from inside another JSON object using the JSON pointer notation as defined in RFC 6901 <a href="https://tools.ietf.org/html/rfc6901">https://tools.ietf.org/html/rfc6901</a></p>
103 <p>The returned JSON sub-object is equivalent to parsing manually the 'obj' JSON tree ; i.e. it's not a new object that is created, but rather a pointer inside the JSON tree.</p>
104 <p>Internally, this is equivalent to doing a series of '<a class="el" href="json__object_8h.html#a1a097805abb53b4c8a60d573730a8939">json_object_object_get()</a>' and '<a class="el" href="json__object_8h.html#a676711a76545d4ec65cc75f100f5fd19">json_object_array_get_idx()</a>' along the given 'path'.</p>
105 <p>Note that the 'path' string supports 'printf()' type arguments, so, whatever is added after the 'res' param will be treated as an argument for 'path' Example: json_pointer_get(obj, "/foo/%d/%s", &amp;res, 0, bar) This means, that you need to escape '' with '%' (just like in printf())</p>
106 <dl class="params"><dt>Parameters</dt><dd>
107   <table class="params">
108     <tr><td class="paramname">obj</td><td>the json_object instance/tree from where to retrieve sub-objects </td></tr>
109     <tr><td class="paramname">path</td><td>a (RFC6901) string notation for the sub-object to retrieve </td></tr>
110     <tr><td class="paramname">res</td><td>a pointer that stores a reference to the json_object associated with the given path</td></tr>
111   </table>
112   </dd>
113 </dl>
114 <dl class="section return"><dt>Returns</dt><dd>negative if an error (or not found), or 0 if succeeded </dd></dl>
115 
116 </div>
117 </div>
118 <a class="anchor" id="af0ac03df64b215d05041e8007ed0233d"></a>
119 <div class="memitem">
120 <div class="memproto">
121       <table class="memname">
122         <tr>
123           <td class="memname"><a class="el" href="printbuf_8h.html#a2a31d5c00f3a4712f2d5d62aee66344e">JSON_EXPORT</a> int json_pointer_getf </td>
124           <td>(</td>
125           <td class="paramtype">struct <a class="el" href="json__types_8h.html#af27907ced0f5a43409ad96430fe0f914">json_object</a> *&#160;</td>
126           <td class="paramname"><em>obj</em>, </td>
127         </tr>
128         <tr>
129           <td class="paramkey"></td>
130           <td></td>
131           <td class="paramtype">struct <a class="el" href="json__types_8h.html#af27907ced0f5a43409ad96430fe0f914">json_object</a> **&#160;</td>
132           <td class="paramname"><em>res</em>, </td>
133         </tr>
134         <tr>
135           <td class="paramkey"></td>
136           <td></td>
137           <td class="paramtype">const char *&#160;</td>
138           <td class="paramname"><em>path_fmt</em>, </td>
139         </tr>
140         <tr>
141           <td class="paramkey"></td>
142           <td></td>
143           <td class="paramtype">&#160;</td>
144           <td class="paramname"><em>...</em>&#160;</td>
145         </tr>
146         <tr>
147           <td></td>
148           <td>)</td>
149           <td></td><td></td>
150         </tr>
151       </table>
152 </div><div class="memdoc">
153 <p>This is a variant of '<a class="el" href="json__pointer_8h.html#aff88937e32b0ba6ffbd07cb4b1919053">json_pointer_get()</a>' that supports printf() style arguments.</p>
154 <p>Example: json_pointer_getf(obj, res, "/foo/%d/%s", 0, bak) This also means that you need to escape '' with '%' (just like in printf())</p>
155 <p>Please take into consideration all recommended 'printf()' format security aspects when using this function.</p>
156 <dl class="params"><dt>Parameters</dt><dd>
157   <table class="params">
158     <tr><td class="paramname">obj</td><td>the json_object instance/tree to which to add a sub-object </td></tr>
159     <tr><td class="paramname">res</td><td>a pointer that stores a reference to the json_object associated with the given path </td></tr>
160     <tr><td class="paramname">path_fmt</td><td>a printf() style format for the path</td></tr>
161   </table>
162   </dd>
163 </dl>
164 <dl class="section return"><dt>Returns</dt><dd>negative if an error (or not found), or 0 if succeeded </dd></dl>
165 
166 </div>
167 </div>
168 <a class="anchor" id="aef0e651f63ce5ce35648503705e2586b"></a>
169 <div class="memitem">
170 <div class="memproto">
171       <table class="memname">
172         <tr>
173           <td class="memname"><a class="el" href="printbuf_8h.html#a2a31d5c00f3a4712f2d5d62aee66344e">JSON_EXPORT</a> int json_pointer_set </td>
174           <td>(</td>
175           <td class="paramtype">struct <a class="el" href="json__types_8h.html#af27907ced0f5a43409ad96430fe0f914">json_object</a> **&#160;</td>
176           <td class="paramname"><em>obj</em>, </td>
177         </tr>
178         <tr>
179           <td class="paramkey"></td>
180           <td></td>
181           <td class="paramtype">const char *&#160;</td>
182           <td class="paramname"><em>path</em>, </td>
183         </tr>
184         <tr>
185           <td class="paramkey"></td>
186           <td></td>
187           <td class="paramtype">struct <a class="el" href="json__types_8h.html#af27907ced0f5a43409ad96430fe0f914">json_object</a> *&#160;</td>
188           <td class="paramname"><em>value</em>&#160;</td>
189         </tr>
190         <tr>
191           <td></td>
192           <td>)</td>
193           <td></td><td></td>
194         </tr>
195       </table>
196 </div><div class="memdoc">
197 <p>Sets JSON object 'value' in the 'obj' tree at the location specified by the 'path'. 'path' is JSON pointer notation as defined in RFC 6901 <a href="https://tools.ietf.org/html/rfc6901">https://tools.ietf.org/html/rfc6901</a></p>
198 <p>Note that 'obj' is a double pointer, mostly for the "" (empty string) case, where the entire JSON object would be replaced by 'value'. In the case of the "" path, the object at '*obj' will have it's refcount decremented with '<a class="el" href="json__object_8h.html#afabf61f932cd64a4122ca8092452eed5">json_object_put()</a>' and the 'value' object will be assigned to it.</p>
199 <p>For other cases (JSON sub-objects) ownership of 'value' will be transferred into '*obj' via '<a class="el" href="json__object_8h.html#a27bd808a022251059a43f1f6370441cd">json_object_object_add()</a>' &amp; '<a class="el" href="json__object_8h.html#a1ac0ccdbc13a25da7d8b2dc9e421dfad">json_object_array_put_idx()</a>', so the only time the refcount should be decremented for 'value' is when the return value of '<a class="el" href="json__pointer_8h.html#aef0e651f63ce5ce35648503705e2586b">json_pointer_set()</a>' is negative (meaning the 'value' object did not get set into '*obj').</p>
200 <p>That also implies that '<a class="el" href="json__pointer_8h.html#aef0e651f63ce5ce35648503705e2586b">json_pointer_set()</a>' does not do any refcount incrementing. (Just that single decrement that was mentioned above).</p>
201 <p>Note that the 'path' string supports 'printf()' type arguments, so, whatever is added after the 'value' param will be treated as an argument for 'path' Example: json_pointer_set(obj, "/foo/%d/%s", value, 0, bak) This means, that you need to escape '' with '%' (just like in printf())</p>
202 <dl class="params"><dt>Parameters</dt><dd>
203   <table class="params">
204     <tr><td class="paramname">obj</td><td>the json_object instance/tree to which to add a sub-object </td></tr>
205     <tr><td class="paramname">path</td><td>a (RFC6901) string notation for the sub-object to set in the tree </td></tr>
206     <tr><td class="paramname">value</td><td>object to set at path</td></tr>
207   </table>
208   </dd>
209 </dl>
210 <dl class="section return"><dt>Returns</dt><dd>negative if an error (or not found), or 0 if succeeded </dd></dl>
211 
212 </div>
213 </div>
214 <a class="anchor" id="a66f1f98a2ce085c19f6750193b4c726d"></a>
215 <div class="memitem">
216 <div class="memproto">
217       <table class="memname">
218         <tr>
219           <td class="memname"><a class="el" href="printbuf_8h.html#a2a31d5c00f3a4712f2d5d62aee66344e">JSON_EXPORT</a> int json_pointer_setf </td>
220           <td>(</td>
221           <td class="paramtype">struct <a class="el" href="json__types_8h.html#af27907ced0f5a43409ad96430fe0f914">json_object</a> **&#160;</td>
222           <td class="paramname"><em>obj</em>, </td>
223         </tr>
224         <tr>
225           <td class="paramkey"></td>
226           <td></td>
227           <td class="paramtype">struct <a class="el" href="json__types_8h.html#af27907ced0f5a43409ad96430fe0f914">json_object</a> *&#160;</td>
228           <td class="paramname"><em>value</em>, </td>
229         </tr>
230         <tr>
231           <td class="paramkey"></td>
232           <td></td>
233           <td class="paramtype">const char *&#160;</td>
234           <td class="paramname"><em>path_fmt</em>, </td>
235         </tr>
236         <tr>
237           <td class="paramkey"></td>
238           <td></td>
239           <td class="paramtype">&#160;</td>
240           <td class="paramname"><em>...</em>&#160;</td>
241         </tr>
242         <tr>
243           <td></td>
244           <td>)</td>
245           <td></td><td></td>
246         </tr>
247       </table>
248 </div><div class="memdoc">
249 <p>This is a variant of '<a class="el" href="json__pointer_8h.html#aef0e651f63ce5ce35648503705e2586b">json_pointer_set()</a>' that supports printf() style arguments.</p>
250 <p>Example: json_pointer_setf(obj, value, "/foo/%d/%s", 0, bak) This also means that you need to escape '' with '%' (just like in printf())</p>
251 <p>Please take into consideration all recommended 'printf()' format security aspects when using this function.</p>
252 <dl class="params"><dt>Parameters</dt><dd>
253   <table class="params">
254     <tr><td class="paramname">obj</td><td>the json_object instance/tree to which to add a sub-object </td></tr>
255     <tr><td class="paramname">value</td><td>object to set at path </td></tr>
256     <tr><td class="paramname">path_fmt</td><td>a printf() style format for the path</td></tr>
257   </table>
258   </dd>
259 </dl>
260 <dl class="section return"><dt>Returns</dt><dd>negative if an error (or not found), or 0 if succeeded </dd></dl>
261 
262 </div>
263 </div>
264 </div><!-- contents -->
265 <!-- start footer part -->
266 <hr class="footer"/><address class="footer"><small>
267 Generated on Sun Jul 26 2020 15:11:19 for json-c by &#160;<a href="http://www.doxygen.org/index.html">
268 <img class="footer" src="doxygen.png" alt="doxygen"/>
269 </a> 1.8.2
270 </small></address>
271 </body>
272 </html>

This page was automatically generated by LXR 0.3.1.  •  OpenWrt