mirror of
https://github.com/json-c/json-c.git
synced 2026-09-07 16:46:50 +08:00
476 lines
29 KiB
HTML
476 lines
29 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
|
|
<meta name="generator" content="Doxygen 1.9.8"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
<title>json-c: json_pointer.h File Reference</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="jquery.js"></script>
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
|
</head>
|
|
<body>
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr id="projectrow">
|
|
<td id="projectalign">
|
|
<div id="projectname">json-c<span id="projectnumber"> 0.19</span>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.9.8 -->
|
|
<script type="text/javascript" src="menudata.js"></script>
|
|
<script type="text/javascript" src="menu.js"></script>
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
|
$(function() {
|
|
initMenu('',false,false,'search.php','Search');
|
|
});
|
|
/* @license-end */
|
|
</script>
|
|
<div id="main-nav"></div>
|
|
</div><!-- top -->
|
|
<div class="header">
|
|
<div class="summary">
|
|
<a href="#typedef-members">Typedefs</a> |
|
|
<a href="#func-members">Functions</a> </div>
|
|
<div class="headertitle"><div class="title">json_pointer.h File Reference</div></div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
|
|
<p>JSON Pointer (RFC 6901) implementation for retrieving objects from a json-c object tree.
|
|
<a href="#details">More...</a></p>
|
|
<table class="memberdecls">
|
|
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="typedef-members" name="typedef-members"></a>
|
|
Typedefs</h2></td></tr>
|
|
<tr class="memitem:a58450e5dba2237e7806d0d273579a3e8" id="r_a58450e5dba2237e7806d0d273579a3e8"><td class="memItemLeft" align="right" valign="top">typedef int(* </td><td class="memItemRight" valign="bottom"><a class="el" href="json__pointer_8h.html#a58450e5dba2237e7806d0d273579a3e8">json_pointer_set_cb</a>) (<a class="el" href="json__types_8h.html#af27907ced0f5a43409ad96430fe0f914">json_object</a> *parent, const char *key, size_t idx, <a class="el" href="json__types_8h.html#af27907ced0f5a43409ad96430fe0f914">json_object</a> *value, void *priv)</td></tr>
|
|
<tr class="separator:a58450e5dba2237e7806d0d273579a3e8"><td class="memSeparator" colspan="2"> </td></tr>
|
|
</table><table class="memberdecls">
|
|
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
|
|
Functions</h2></td></tr>
|
|
<tr class="memitem:aff88937e32b0ba6ffbd07cb4b1919053" id="r_aff88937e32b0ba6ffbd07cb4b1919053"><td class="memItemLeft" align="right" valign="top"><a class="el" href="json__c__version_8h.html#a2a31d5c00f3a4712f2d5d62aee66344e">JSON_EXPORT</a> int </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>
|
|
<tr class="separator:aff88937e32b0ba6ffbd07cb4b1919053"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:af0ac03df64b215d05041e8007ed0233d" id="r_af0ac03df64b215d05041e8007ed0233d"><td class="memItemLeft" align="right" valign="top"><a class="el" href="json__c__version_8h.html#a2a31d5c00f3a4712f2d5d62aee66344e">JSON_EXPORT</a> int </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>
|
|
<tr class="separator:af0ac03df64b215d05041e8007ed0233d"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:aef0e651f63ce5ce35648503705e2586b" id="r_aef0e651f63ce5ce35648503705e2586b"><td class="memItemLeft" align="right" valign="top"><a class="el" href="json__c__version_8h.html#a2a31d5c00f3a4712f2d5d62aee66344e">JSON_EXPORT</a> int </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>
|
|
<tr class="separator:aef0e651f63ce5ce35648503705e2586b"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a66f1f98a2ce085c19f6750193b4c726d" id="r_a66f1f98a2ce085c19f6750193b4c726d"><td class="memItemLeft" align="right" valign="top"><a class="el" href="json__c__version_8h.html#a2a31d5c00f3a4712f2d5d62aee66344e">JSON_EXPORT</a> int </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>
|
|
<tr class="separator:a66f1f98a2ce085c19f6750193b4c726d"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a81d3e45879dae6150f1a7819ffe5fcd7" id="r_a81d3e45879dae6150f1a7819ffe5fcd7"><td class="memItemLeft" align="right" valign="top"><a class="el" href="json__c__version_8h.html#a2a31d5c00f3a4712f2d5d62aee66344e">JSON_EXPORT</a> int </td><td class="memItemRight" valign="bottom"><a class="el" href="json__pointer_8h.html#a81d3e45879dae6150f1a7819ffe5fcd7">json_pointer_set_with_limit_index</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, size_t limit_index)</td></tr>
|
|
<tr class="separator:a81d3e45879dae6150f1a7819ffe5fcd7"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a24b95b507aa5369535779881d737ac46" id="r_a24b95b507aa5369535779881d737ac46"><td class="memItemLeft" align="right" valign="top"><a class="el" href="json__c__version_8h.html#a2a31d5c00f3a4712f2d5d62aee66344e">JSON_EXPORT</a> int </td><td class="memItemRight" valign="bottom"><a class="el" href="json__pointer_8h.html#a24b95b507aa5369535779881d737ac46">json_pointer_set_with_cb</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, <a class="el" href="json__pointer_8h.html#a58450e5dba2237e7806d0d273579a3e8">json_pointer_set_cb</a> set_cb, int cb_handles_obj, void *priv)</td></tr>
|
|
<tr class="separator:a24b95b507aa5369535779881d737ac46"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:aeb54a4c7763a4febc2ef83694d5c036e" id="r_aeb54a4c7763a4febc2ef83694d5c036e"><td class="memItemLeft" align="right" valign="top"><a class="el" href="json__c__version_8h.html#a2a31d5c00f3a4712f2d5d62aee66344e">JSON_EXPORT</a> int </td><td class="memItemRight" valign="bottom"><a class="el" href="json__pointer_8h.html#aeb54a4c7763a4febc2ef83694d5c036e">json_object_array_put_with_idx_limit_cb</a> (struct <a class="el" href="json__types_8h.html#af27907ced0f5a43409ad96430fe0f914">json_object</a> *jso, const char *key, size_t idx, struct <a class="el" href="json__types_8h.html#af27907ced0f5a43409ad96430fe0f914">json_object</a> *jso_new, void *priv)</td></tr>
|
|
<tr class="separator:aeb54a4c7763a4febc2ef83694d5c036e"><td class="memSeparator" colspan="2"> </td></tr>
|
|
</table>
|
|
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
|
<div class="textblock"><p>JSON Pointer (RFC 6901) implementation for retrieving objects from a json-c object tree. </p>
|
|
</div><h2 class="groupheader">Typedef Documentation</h2>
|
|
<a id="a58450e5dba2237e7806d0d273579a3e8" name="a58450e5dba2237e7806d0d273579a3e8"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a58450e5dba2237e7806d0d273579a3e8">◆ </a></span>json_pointer_set_cb</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">typedef int(* json_pointer_set_cb) (<a class="el" href="json__types_8h.html#af27907ced0f5a43409ad96430fe0f914">json_object</a> *parent, const char *key, size_t idx, <a class="el" href="json__types_8h.html#af27907ced0f5a43409ad96430fe0f914">json_object</a> *value, void *priv)</td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
<p>Callback function type.</p>
|
|
<p>When setting an array element, 'key' will be NULL and 'idx' will be the target index. When setting an object field, 'key' will be the target key and 'idx' will be -1. </p>
|
|
|
|
</div>
|
|
</div>
|
|
<h2 class="groupheader">Function Documentation</h2>
|
|
<a id="aeb54a4c7763a4febc2ef83694d5c036e" name="aeb54a4c7763a4febc2ef83694d5c036e"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#aeb54a4c7763a4febc2ef83694d5c036e">◆ </a></span>json_object_array_put_with_idx_limit_cb()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname"><a class="el" href="json__c__version_8h.html#a2a31d5c00f3a4712f2d5d62aee66344e">JSON_EXPORT</a> int json_object_array_put_with_idx_limit_cb </td>
|
|
<td>(</td>
|
|
<td class="paramtype">struct <a class="el" href="json__types_8h.html#af27907ced0f5a43409ad96430fe0f914">json_object</a> * </td>
|
|
<td class="paramname"><em>jso</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">const char * </td>
|
|
<td class="paramname"><em>key</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">size_t </td>
|
|
<td class="paramname"><em>idx</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">struct <a class="el" href="json__types_8h.html#af27907ced0f5a43409ad96430fe0f914">json_object</a> * </td>
|
|
<td class="paramname"><em>jso_new</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">void * </td>
|
|
<td class="paramname"><em>priv</em> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
<p>A safer callback for '<a class="el" href="json__pointer_8h.html#a24b95b507aa5369535779881d737ac46">json_pointer_set_with_cb()</a>' that enforces a maximum array index.</p>
|
|
<p>This function can be used as the 'set_cb' argument to prevent OOM. It expects the 'priv' argument to be a valid pointer to a 'size_t' variable that holds the maximum allowed index.</p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">jso</td><td>the parent json_object array. </td></tr>
|
|
<tr><td class="paramname">key</td><td>the object field where the element is to be placed, should be NULL here. </td></tr>
|
|
<tr><td class="paramname">idx</td><td>the index where the element is to be placed. </td></tr>
|
|
<tr><td class="paramname">jso_new</td><td>the new json_object to place at the index. </td></tr>
|
|
<tr><td class="paramname">priv</td><td>A pointer to a 'size_t' variable specifying the maximum index. This pointer must not be NULL.</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>0 on success, or a negative value if idx exceeds the limit or 'priv' is NULL. </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="aff88937e32b0ba6ffbd07cb4b1919053" name="aff88937e32b0ba6ffbd07cb4b1919053"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#aff88937e32b0ba6ffbd07cb4b1919053">◆ </a></span>json_pointer_get()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname"><a class="el" href="json__c__version_8h.html#a2a31d5c00f3a4712f2d5d62aee66344e">JSON_EXPORT</a> int json_pointer_get </td>
|
|
<td>(</td>
|
|
<td class="paramtype">struct <a class="el" href="json__types_8h.html#af27907ced0f5a43409ad96430fe0f914">json_object</a> * </td>
|
|
<td class="paramname"><em>obj</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">const char * </td>
|
|
<td class="paramname"><em>path</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">struct <a class="el" href="json__types_8h.html#af27907ced0f5a43409ad96430fe0f914">json_object</a> ** </td>
|
|
<td class="paramname"><em>res</em> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
<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>
|
|
<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>
|
|
<p>Internally, this is equivalent to doing a series of '<a class="el" href="json__object_8h.html#af7a569d69c3b90e79af7ef21e557e402">json_object_object_get()</a>' and '<a class="el" href="json__object_8h.html#af229a1625af2aae7116a0bd6fb1e5ad2">json_object_array_get_idx()</a>' along the given 'path'.</p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">obj</td><td>the json_object instance/tree from where to retrieve sub-objects </td></tr>
|
|
<tr><td class="paramname">path</td><td>a (RFC6901) string notation for the sub-object to retrieve </td></tr>
|
|
<tr><td class="paramname">res</td><td>a pointer that stores a reference to the json_object associated with the given path</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>negative if an error (or not found), or 0 if succeeded </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="af0ac03df64b215d05041e8007ed0233d" name="af0ac03df64b215d05041e8007ed0233d"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#af0ac03df64b215d05041e8007ed0233d">◆ </a></span>json_pointer_getf()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname"><a class="el" href="json__c__version_8h.html#a2a31d5c00f3a4712f2d5d62aee66344e">JSON_EXPORT</a> int json_pointer_getf </td>
|
|
<td>(</td>
|
|
<td class="paramtype">struct <a class="el" href="json__types_8h.html#af27907ced0f5a43409ad96430fe0f914">json_object</a> * </td>
|
|
<td class="paramname"><em>obj</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">struct <a class="el" href="json__types_8h.html#af27907ced0f5a43409ad96430fe0f914">json_object</a> ** </td>
|
|
<td class="paramname"><em>res</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">const char * </td>
|
|
<td class="paramname"><em>path_fmt</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype"> </td>
|
|
<td class="paramname"><em>...</em> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
<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>
|
|
<p>Variable arguments go after the 'path_fmt' parameter.</p>
|
|
<p>Example: json_pointer_getf(obj, res, "/foo/%d/%s", 0, "bar") This also means that you need to escape '' with '%' (just like in printf())</p>
|
|
<p>Please take into consideration all recommended 'printf()' format security aspects when using this function.</p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">obj</td><td>the json_object instance/tree to which to add a sub-object </td></tr>
|
|
<tr><td class="paramname">res</td><td>a pointer that stores a reference to the json_object associated with the given path </td></tr>
|
|
<tr><td class="paramname">path_fmt</td><td>a printf() style format for the path</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>negative if an error (or not found), or 0 if succeeded </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="aef0e651f63ce5ce35648503705e2586b" name="aef0e651f63ce5ce35648503705e2586b"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#aef0e651f63ce5ce35648503705e2586b">◆ </a></span>json_pointer_set()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname"><a class="el" href="json__c__version_8h.html#a2a31d5c00f3a4712f2d5d62aee66344e">JSON_EXPORT</a> int json_pointer_set </td>
|
|
<td>(</td>
|
|
<td class="paramtype">struct <a class="el" href="json__types_8h.html#af27907ced0f5a43409ad96430fe0f914">json_object</a> ** </td>
|
|
<td class="paramname"><em>obj</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">const char * </td>
|
|
<td class="paramname"><em>path</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">struct <a class="el" href="json__types_8h.html#af27907ced0f5a43409ad96430fe0f914">json_object</a> * </td>
|
|
<td class="paramname"><em>value</em> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
<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>
|
|
<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>
|
|
<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#aef0e651f63ce5ce35648503705e2586b">json_pointer_set()</a>' is negative (meaning the 'value' object did not get set into '*obj').</p>
|
|
<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>
|
|
<dl class="section warning"><dt>Warning</dt><dd>This function is vulnerable to an OOM. To prevent this, use the safer variant '<a class="el" href="json__pointer_8h.html#a81d3e45879dae6150f1a7819ffe5fcd7">json_pointer_set_with_limit_index()</a>' or the flexible 'json_pointer_set_with_array_cb()' with a custom callback.</dd></dl>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">obj</td><td>the json_object instance/tree to which to add a sub-object </td></tr>
|
|
<tr><td class="paramname">path</td><td>a (RFC6901) string notation for the sub-object to set in the tree </td></tr>
|
|
<tr><td class="paramname">value</td><td>object to set at path</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>negative if an error (or not found), or 0 if succeeded </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="a24b95b507aa5369535779881d737ac46" name="a24b95b507aa5369535779881d737ac46"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a24b95b507aa5369535779881d737ac46">◆ </a></span>json_pointer_set_with_cb()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname"><a class="el" href="json__c__version_8h.html#a2a31d5c00f3a4712f2d5d62aee66344e">JSON_EXPORT</a> int json_pointer_set_with_cb </td>
|
|
<td>(</td>
|
|
<td class="paramtype">struct <a class="el" href="json__types_8h.html#af27907ced0f5a43409ad96430fe0f914">json_object</a> ** </td>
|
|
<td class="paramname"><em>obj</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">const char * </td>
|
|
<td class="paramname"><em>path</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">struct <a class="el" href="json__types_8h.html#af27907ced0f5a43409ad96430fe0f914">json_object</a> * </td>
|
|
<td class="paramname"><em>value</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype"><a class="el" href="json__pointer_8h.html#a58450e5dba2237e7806d0d273579a3e8">json_pointer_set_cb</a> </td>
|
|
<td class="paramname"><em>set_cb</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">int </td>
|
|
<td class="paramname"><em>cb_handles_obj</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">void * </td>
|
|
<td class="paramname"><em>priv</em> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
<p>Variant of '<a class="el" href="json__pointer_8h.html#aef0e651f63ce5ce35648503705e2586b">json_pointer_set()</a>' that allows specifying a custom callback</p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">obj</td><td>the json_object instance/tree to which to add a sub-object </td></tr>
|
|
<tr><td class="paramname">path</td><td>a (RFC6901) string notation for the sub-object to set in the tree </td></tr>
|
|
<tr><td class="paramname">value</td><td>object to set at path </td></tr>
|
|
<tr><td class="paramname">set_cb</td><td>A custom callback function to handle setting the element </td></tr>
|
|
<tr><td class="paramname">cb_handles_obj</td><td>If 0, the callback is only invoked for array modifications. If 1, the callback is invoked for both array and object modifications. </td></tr>
|
|
<tr><td class="paramname">priv</td><td>A private pointer passed through to the set_cb callback, for user-defined context</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>negative if an error (or not found), or 0 if succeeded </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="a81d3e45879dae6150f1a7819ffe5fcd7" name="a81d3e45879dae6150f1a7819ffe5fcd7"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a81d3e45879dae6150f1a7819ffe5fcd7">◆ </a></span>json_pointer_set_with_limit_index()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname"><a class="el" href="json__c__version_8h.html#a2a31d5c00f3a4712f2d5d62aee66344e">JSON_EXPORT</a> int json_pointer_set_with_limit_index </td>
|
|
<td>(</td>
|
|
<td class="paramtype">struct <a class="el" href="json__types_8h.html#af27907ced0f5a43409ad96430fe0f914">json_object</a> ** </td>
|
|
<td class="paramname"><em>obj</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">const char * </td>
|
|
<td class="paramname"><em>path</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">struct <a class="el" href="json__types_8h.html#af27907ced0f5a43409ad96430fe0f914">json_object</a> * </td>
|
|
<td class="paramname"><em>value</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">size_t </td>
|
|
<td class="paramname"><em>limit_index</em> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
<p>A convenient and safe variant of '<a class="el" href="json__pointer_8h.html#aef0e651f63ce5ce35648503705e2586b">json_pointer_set()</a>' that prevents excessive memory allocations by enforcing a limit on array indices.</p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">obj</td><td>the json_object instance/tree to which to add a sub-object </td></tr>
|
|
<tr><td class="paramname">path</td><td>a (RFC6901) string notation for the sub-object to set in the tree </td></tr>
|
|
<tr><td class="paramname">value</td><td>object to set at path </td></tr>
|
|
<tr><td class="paramname">limit_index</td><td>The maximum allowed value for an array index. If a path contains an index larger than this, the function will fail with errno set to EINVAL. A value of -1 can be used to specify no limit, reverting to the original behavior</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>negative if an error (or not found), or 0 if succeeded </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="a66f1f98a2ce085c19f6750193b4c726d" name="a66f1f98a2ce085c19f6750193b4c726d"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a66f1f98a2ce085c19f6750193b4c726d">◆ </a></span>json_pointer_setf()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname"><a class="el" href="json__c__version_8h.html#a2a31d5c00f3a4712f2d5d62aee66344e">JSON_EXPORT</a> int json_pointer_setf </td>
|
|
<td>(</td>
|
|
<td class="paramtype">struct <a class="el" href="json__types_8h.html#af27907ced0f5a43409ad96430fe0f914">json_object</a> ** </td>
|
|
<td class="paramname"><em>obj</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">struct <a class="el" href="json__types_8h.html#af27907ced0f5a43409ad96430fe0f914">json_object</a> * </td>
|
|
<td class="paramname"><em>value</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">const char * </td>
|
|
<td class="paramname"><em>path_fmt</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype"> </td>
|
|
<td class="paramname"><em>...</em> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
<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>
|
|
<p>Variable arguments go after the 'path_fmt' parameter.</p>
|
|
<p>Example: json_pointer_setf(obj, value, "/foo/%d/%s", 0, "bar") This also means that you need to escape '' with '%' (just like in printf())</p>
|
|
<p>Please take into consideration all recommended 'printf()' format security aspects when using this function.</p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">obj</td><td>the json_object instance/tree to which to add a sub-object </td></tr>
|
|
<tr><td class="paramname">value</td><td>object to set at path </td></tr>
|
|
<tr><td class="paramname">path_fmt</td><td>a printf() style format for the path</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>negative if an error (or not found), or 0 if succeeded </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
</div><!-- contents -->
|
|
<!-- start footer part -->
|
|
<hr class="footer"/><address class="footer"><small>
|
|
Generated on Sat Jun 27 2026 09:45:24 for json-c by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.8
|
|
</small></address>
|
|
</body>
|
|
</html>
|