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">
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_pointer.h File Reference</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" />
14 <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
16 <table cellspacing="0" cellpadding="0">
18 <tr style="height: 56px;">
19 <td style="padding-left: 0.5em;">
20 <div id="projectname">json-c
21  <span id="projectnumber">0.13.1</span>
28 <!-- end header part -->
29 <!-- Generated by Doxygen 1.8.8 -->
30 <div id="navrow1" class="tabs">
32 <li><a href="index.html"><span>Main Page</span></a></li>
33 <li><a href="pages.html"><span>Related Pages</span></a></li>
34 <li><a href="annotated.html"><span>Data Structures</span></a></li>
35 <li class="current"><a href="files.html"><span>Files</span></a></li>
38 <div id="navrow2" class="tabs2">
40 <li><a href="files.html"><span>File List</span></a></li>
41 <li><a href="globals.html"><span>Globals</span></a></li>
47 <a href="#func-members">Functions</a> </div>
48 <div class="headertitle">
49 <div class="title">json_pointer.h File Reference</div> </div>
51 <div class="contents">
53 <p>JSON Pointer (RFC 6901) implementation for retrieving objects from a json-c object tree.
54 <a href="#details">More...</a></p>
55 <table class="memberdecls">
56 <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
57 Functions</h2></td></tr>
58 <tr class="memitem:abf47f34be3386a5eb510604f05ae9491"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="json__pointer_8h.html#abf47f34be3386a5eb510604f05ae9491">json_pointer_get</a> (struct <a class="el" href="structjson__object.html">json_object</a> *obj, const char *path, struct <a class="el" href="structjson__object.html">json_object</a> **res)</td></tr>
59 <tr class="separator:abf47f34be3386a5eb510604f05ae9491"><td class="memSeparator" colspan="2"> </td></tr>
60 <tr class="memitem:ae7eb2cab2f6f50c51053430223a01438"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="json__pointer_8h.html#ae7eb2cab2f6f50c51053430223a01438">json_pointer_getf</a> (struct <a class="el" href="structjson__object.html">json_object</a> *obj, struct <a class="el" href="structjson__object.html">json_object</a> **res, const char *path_fmt,...)</td></tr>
61 <tr class="separator:ae7eb2cab2f6f50c51053430223a01438"><td class="memSeparator" colspan="2"> </td></tr>
62 <tr class="memitem:ab06a9fd172593748b2dc8d3a11c74fa0"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="json__pointer_8h.html#ab06a9fd172593748b2dc8d3a11c74fa0">json_pointer_set</a> (struct <a class="el" href="structjson__object.html">json_object</a> **obj, const char *path, struct <a class="el" href="structjson__object.html">json_object</a> *value)</td></tr>
63 <tr class="separator:ab06a9fd172593748b2dc8d3a11c74fa0"><td class="memSeparator" colspan="2"> </td></tr>
64 <tr class="memitem:a74edfbe357c7428b1a20ae73e3910ac0"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="json__pointer_8h.html#a74edfbe357c7428b1a20ae73e3910ac0">json_pointer_setf</a> (struct <a class="el" href="structjson__object.html">json_object</a> **obj, struct <a class="el" href="structjson__object.html">json_object</a> *value, const char *path_fmt,...)</td></tr>
65 <tr class="separator:a74edfbe357c7428b1a20ae73e3910ac0"><td class="memSeparator" colspan="2"> </td></tr>
67 <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
68 <div class="textblock"><p>JSON Pointer (RFC 6901) implementation for retrieving objects from a json-c object tree. </p>
69 </div><h2 class="groupheader">Function Documentation</h2>
70 <a class="anchor" id="abf47f34be3386a5eb510604f05ae9491"></a>
72 <div class="memproto">
73 <table class="memname">
75 <td class="memname">int json_pointer_get </td>
77 <td class="paramtype">struct <a class="el" href="structjson__object.html">json_object</a> * </td>
78 <td class="paramname"><em>obj</em>, </td>
81 <td class="paramkey"></td>
83 <td class="paramtype">const char * </td>
84 <td class="paramname"><em>path</em>, </td>
87 <td class="paramkey"></td>
89 <td class="paramtype">struct <a class="el" href="structjson__object.html">json_object</a> ** </td>
90 <td class="paramname"><em>res</em> </td>
98 </div><div class="memdoc">
99 <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>
100 <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>
101 <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>
102 <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", &res, 0, bar) This means, that you need to escape '' with '%' (just like in printf())</p>
103 <dl class="params"><dt>Parameters</dt><dd>
104 <table class="params">
105 <tr><td class="paramname">obj</td><td>the <a class="el" href="structjson__object.html">json_object</a> instance/tree from where to retrieve sub-objects </td></tr>
106 <tr><td class="paramname">path</td><td>a (RFC6901) string notation for the sub-object to retrieve </td></tr>
107 <tr><td class="paramname">res</td><td>a pointer where to store a reference to the <a class="el" href="structjson__object.html">json_object</a> associated with the given path</td></tr>
111 <dl class="section return"><dt>Returns</dt><dd>negative if an error (or not found), or 0 if succeeded </dd></dl>
115 <a class="anchor" id="ae7eb2cab2f6f50c51053430223a01438"></a>
116 <div class="memitem">
117 <div class="memproto">
118 <table class="memname">
120 <td class="memname">int json_pointer_getf </td>
122 <td class="paramtype">struct <a class="el" href="structjson__object.html">json_object</a> * </td>
123 <td class="paramname"><em>obj</em>, </td>
126 <td class="paramkey"></td>
128 <td class="paramtype">struct <a class="el" href="structjson__object.html">json_object</a> ** </td>
129 <td class="paramname"><em>res</em>, </td>
132 <td class="paramkey"></td>
134 <td class="paramtype">const char * </td>
135 <td class="paramname"><em>path_fmt</em>, </td>
138 <td class="paramkey"></td>
140 <td class="paramtype"> </td>
141 <td class="paramname"><em>...</em> </td>
149 </div><div class="memdoc">
150 <p>This is a variant of '<a class="el" href="json__pointer_8h.html#abf47f34be3386a5eb510604f05ae9491">json_pointer_get()</a>' that supports printf() style arguments.</p>
151 <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>
152 <p>Please take into consideration all recommended 'printf()' format security aspects when using this function.</p>
153 <dl class="params"><dt>Parameters</dt><dd>
154 <table class="params">
155 <tr><td class="paramname">obj</td><td>the <a class="el" href="structjson__object.html">json_object</a> instance/tree to which to add a sub-object </td></tr>
156 <tr><td class="paramname">res</td><td>a pointer where to store a reference to the <a class="el" href="structjson__object.html">json_object</a> associated with the given path </td></tr>
157 <tr><td class="paramname">path_fmt</td><td>a printf() style format for the path</td></tr>
161 <dl class="section return"><dt>Returns</dt><dd>negative if an error (or not found), or 0 if succeeded </dd></dl>
165 <a class="anchor" id="ab06a9fd172593748b2dc8d3a11c74fa0"></a>
166 <div class="memitem">
167 <div class="memproto">
168 <table class="memname">
170 <td class="memname">int json_pointer_set </td>
172 <td class="paramtype">struct <a class="el" href="structjson__object.html">json_object</a> ** </td>
173 <td class="paramname"><em>obj</em>, </td>
176 <td class="paramkey"></td>
178 <td class="paramtype">const char * </td>
179 <td class="paramname"><em>path</em>, </td>
182 <td class="paramkey"></td>
184 <td class="paramtype">struct <a class="el" href="structjson__object.html">json_object</a> * </td>
185 <td class="paramname"><em>value</em> </td>
193 </div><div class="memdoc">
194 <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>
195 <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>
196 <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>' & '<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#ab06a9fd172593748b2dc8d3a11c74fa0">json_pointer_set()</a>' is negative (meaning the 'value' object did not get set into '*obj').</p>
197 <p>That also implies that '<a class="el" href="json__pointer_8h.html#ab06a9fd172593748b2dc8d3a11c74fa0">json_pointer_set()</a>' does not do any refcount incrementing. (Just that single decrement that was mentioned above).</p>
198 <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>
199 <dl class="params"><dt>Parameters</dt><dd>
200 <table class="params">
201 <tr><td class="paramname">obj</td><td>the <a class="el" href="structjson__object.html">json_object</a> instance/tree to which to add a sub-object </td></tr>
202 <tr><td class="paramname">path</td><td>a (RFC6901) string notation for the sub-object to set in the tree </td></tr>
203 <tr><td class="paramname">value</td><td>object to set at path</td></tr>
207 <dl class="section return"><dt>Returns</dt><dd>negative if an error (or not found), or 0 if succeeded </dd></dl>
211 <a class="anchor" id="a74edfbe357c7428b1a20ae73e3910ac0"></a>
212 <div class="memitem">
213 <div class="memproto">
214 <table class="memname">
216 <td class="memname">int json_pointer_setf </td>
218 <td class="paramtype">struct <a class="el" href="structjson__object.html">json_object</a> ** </td>
219 <td class="paramname"><em>obj</em>, </td>
222 <td class="paramkey"></td>
224 <td class="paramtype">struct <a class="el" href="structjson__object.html">json_object</a> * </td>
225 <td class="paramname"><em>value</em>, </td>
228 <td class="paramkey"></td>
230 <td class="paramtype">const char * </td>
231 <td class="paramname"><em>path_fmt</em>, </td>
234 <td class="paramkey"></td>
236 <td class="paramtype"> </td>
237 <td class="paramname"><em>...</em> </td>
245 </div><div class="memdoc">
246 <p>This is a variant of '<a class="el" href="json__pointer_8h.html#ab06a9fd172593748b2dc8d3a11c74fa0">json_pointer_set()</a>' that supports printf() style arguments.</p>
247 <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>
248 <p>Please take into consideration all recommended 'printf()' format security aspects when using this function.</p>
249 <dl class="params"><dt>Parameters</dt><dd>
250 <table class="params">
251 <tr><td class="paramname">obj</td><td>the <a class="el" href="structjson__object.html">json_object</a> instance/tree to which to add a sub-object </td></tr>
252 <tr><td class="paramname">value</td><td>object to set at path </td></tr>
253 <tr><td class="paramname">path_fmt</td><td>a printf() style format for the path</td></tr>
257 <dl class="section return"><dt>Returns</dt><dd>negative if an error (or not found), or 0 if succeeded </dd></dl>
261 </div><!-- contents -->
262 <!-- start footer part -->
263 <hr class="footer"/><address class="footer"><small>
264 Generated on Mon Mar 5 2018 23:17:09 for json-c by  <a href="http://www.doxygen.org/index.html">
265 <img class="footer" src="doxygen.png" alt="doxygen"/>