/usr/share/gtk-doc/html/json-glib/json-glib-JSON-GVariant-Integration.html is in libjson-glib-doc 0.16.2-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSON GVariant Integration</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<link rel="home" href="index.html" title="JSON-GLib Reference Manual">
<link rel="up" href="json-advanced.html" title="Part IV. JSON-GLib Advanced API">
<link rel="prev" href="json-glib-Boxed-Types-Serialization.html" title="Boxed Types Serialization">
<link rel="next" href="json-tools.html" title="Part V. JSON-GLib Additional Reference">
<meta name="generator" content="GTK-Doc V1.19 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="json-glib-Boxed-Types-Serialization.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="json-advanced.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">JSON-GLib Reference Manual</th>
<td><a accesskey="n" href="json-tools.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts">
<a href="#json-glib-JSON-GVariant-Integration.synopsis" class="shortcut">Top</a>
|
<a href="#json-glib-JSON-GVariant-Integration.description" class="shortcut">Description</a>
</td></tr>
</table>
<div class="refentry">
<a name="json-glib-JSON-GVariant-Integration"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="json-glib-JSON-GVariant-Integration.top_of_page"></a>JSON GVariant Integration</span></h2>
<p>JSON GVariant Integration — Serialize and deserialize GVariant types</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<a name="json-glib-JSON-GVariant-Integration.synopsis"></a><h2>Synopsis</h2>
<pre class="synopsis"><a class="link" href="json-glib-JSON-Node.html#JsonNode" title="JsonNode"><span class="returnvalue">JsonNode</span></a> * <a class="link" href="json-glib-JSON-GVariant-Integration.html#json-gvariant-serialize" title="json_gvariant_serialize ()">json_gvariant_serialize</a> (<em class="parameter"><code><span class="type">GVariant</span> *variant</code></em>);
<span class="returnvalue">gchar</span> * <a class="link" href="json-glib-JSON-GVariant-Integration.html#json-gvariant-serialize-data" title="json_gvariant_serialize_data ()">json_gvariant_serialize_data</a> (<em class="parameter"><code><span class="type">GVariant</span> *variant</code></em>,
<em class="parameter"><code><span class="type">gsize</span> *length</code></em>);
<span class="returnvalue">GVariant</span> * <a class="link" href="json-glib-JSON-GVariant-Integration.html#json-gvariant-deserialize" title="json_gvariant_deserialize ()">json_gvariant_deserialize</a> (<em class="parameter"><code><a class="link" href="json-glib-JSON-Node.html#JsonNode" title="JsonNode"><span class="type">JsonNode</span></a> *json_node</code></em>,
<em class="parameter"><code>const <span class="type">gchar</span> *signature</code></em>,
<em class="parameter"><code><span class="type">GError</span> **error</code></em>);
<span class="returnvalue">GVariant</span> * <a class="link" href="json-glib-JSON-GVariant-Integration.html#json-gvariant-deserialize-data" title="json_gvariant_deserialize_data ()">json_gvariant_deserialize_data</a> (<em class="parameter"><code>const <span class="type">gchar</span> *json</code></em>,
<em class="parameter"><code><span class="type">gssize</span> length</code></em>,
<em class="parameter"><code>const <span class="type">gchar</span> *signature</code></em>,
<em class="parameter"><code><span class="type">GError</span> **error</code></em>);
</pre>
</div>
<div class="refsect1">
<a name="json-glib-JSON-GVariant-Integration.description"></a><h2>Description</h2>
<p>
Use <a class="link" href="json-glib-JSON-GVariant-Integration.html#json-gvariant-serialize" title="json_gvariant_serialize ()"><code class="function">json_gvariant_serialize()</code></a> and <a class="link" href="json-glib-JSON-GVariant-Integration.html#json-gvariant-serialize-data" title="json_gvariant_serialize_data ()"><code class="function">json_gvariant_serialize_data()</code></a> to
convert from any <span class="type">GVariant</span> value to a <a class="link" href="json-glib-JSON-Node.html#JsonNode" title="JsonNode"><span class="type">JsonNode</span></a> tree or its string
representation.
</p>
<p>
Use <a class="link" href="json-glib-JSON-GVariant-Integration.html#json-gvariant-deserialize" title="json_gvariant_deserialize ()"><code class="function">json_gvariant_deserialize()</code></a> and <a class="link" href="json-glib-JSON-GVariant-Integration.html#json-gvariant-deserialize-data" title="json_gvariant_deserialize_data ()"><code class="function">json_gvariant_deserialize_data()</code></a> to
obtain the <span class="type">GVariant</span> value from a <a class="link" href="json-glib-JSON-Node.html#JsonNode" title="JsonNode"><span class="type">JsonNode</span></a> tree or directly from a JSON
string.
</p>
<p>
Since many <span class="type">GVariant</span> data types cannot be directly represented as
JSON, a <span class="type">GVariant</span> type string (signature) should be provided to these
methods in order to obtain a correct, type-contrained result.
If no signature is provided, conversion can still be done, but the
resulting <span class="type">GVariant</span> value will be "guessed" from the JSON data types,
according to the following table:
</p>
<p>
</p>
<div class="table">
<a name="id-1.5.5.4.5.1"></a><p class="title"><b>Table 2. Default JSON to GVariant conversion (without signature constrains)</b></p>
<div class="table-contents"><table summary="Default JSON to GVariant conversion (without signature constrains)" border="1">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th align="left">JSON</th>
<th align="left">GVariant</th>
</tr></thead>
<tfoot>
<tr>
<th align="left">string</th>
<th align="left">string (s)</th>
</tr>
<tr>
<th align="left">int64</th>
<th align="left">int64 (x)</th>
</tr>
<tr>
<th align="left">boolean</th>
<th align="left">boolean (b)</th>
</tr>
<tr>
<th align="left">double</th>
<th align="left">double (d)</th>
</tr>
<tr>
<th align="left">array</th>
<th align="left">array of variants (av)</th>
</tr>
<tr>
<th align="left">object</th>
<th align="left">dictionary of string-variant (a{sv})</th>
</tr>
<tr>
<th align="left">null</th>
<th align="left">maybe variant (mv)</th>
</tr>
</tfoot>
</table></div>
</div>
<p><br class="table-break">
</p>
</div>
<div class="refsect1">
<a name="json-glib-JSON-GVariant-Integration.details"></a><h2>Details</h2>
<div class="refsect2">
<a name="json-gvariant-serialize"></a><h3>json_gvariant_serialize ()</h3>
<pre class="programlisting"><a class="link" href="json-glib-JSON-Node.html#JsonNode" title="JsonNode"><span class="returnvalue">JsonNode</span></a> * json_gvariant_serialize (<em class="parameter"><code><span class="type">GVariant</span> *variant</code></em>);</pre>
<p>
Converts <em class="parameter"><code>variant</code></em> to a JSON tree.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>variant</code></em> :</span></p></td>
<td>A <span class="type">GVariant</span> to convert</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>A <a class="link" href="json-glib-JSON-Node.html#JsonNode" title="JsonNode"><span class="type">JsonNode</span></a> representing the root of the
JSON data structure obtained from <em class="parameter"><code>variant</code></em>. <span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span>
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 0.14</p>
</div>
<hr>
<div class="refsect2">
<a name="json-gvariant-serialize-data"></a><h3>json_gvariant_serialize_data ()</h3>
<pre class="programlisting"><span class="returnvalue">gchar</span> * json_gvariant_serialize_data (<em class="parameter"><code><span class="type">GVariant</span> *variant</code></em>,
<em class="parameter"><code><span class="type">gsize</span> *length</code></em>);</pre>
<p>
Converts <em class="parameter"><code>variant</code></em> to its JSON encoded string representation. This method
is actually a helper function. It uses <a class="link" href="json-glib-JSON-GVariant-Integration.html#json-gvariant-serialize" title="json_gvariant_serialize ()"><code class="function">json_gvariant_serialize()</code></a> to obtain the
JSON tree, and then <a class="link" href="JsonGenerator.html" title="JsonGenerator"><span class="type">JsonGenerator</span></a> to stringify it.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>variant</code></em> :</span></p></td>
<td>A <span class="type">GVariant</span> to convert</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>length</code></em> :</span></p></td>
<td>Return location for the length of the returned
string, or <code class="literal">NULL</code>. <span class="annotation">[<acronym title="Parameter for returning results. Default is transfer full."><span class="acronym">out</span></acronym>][<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>The JSON encoded string corresponding to
<em class="parameter"><code>variant</code></em>. <span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span>
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 0.14</p>
</div>
<hr>
<div class="refsect2">
<a name="json-gvariant-deserialize"></a><h3>json_gvariant_deserialize ()</h3>
<pre class="programlisting"><span class="returnvalue">GVariant</span> * json_gvariant_deserialize (<em class="parameter"><code><a class="link" href="json-glib-JSON-Node.html#JsonNode" title="JsonNode"><span class="type">JsonNode</span></a> *json_node</code></em>,
<em class="parameter"><code>const <span class="type">gchar</span> *signature</code></em>,
<em class="parameter"><code><span class="type">GError</span> **error</code></em>);</pre>
<p>
Converts a JSON data structure to a GVariant value using <em class="parameter"><code>signature</code></em> to
resolve ambiguous data types. If no error occurs, the resulting <span class="type">GVariant</span>
is guaranteed to conform to <em class="parameter"><code>signature</code></em>.
</p>
<p>
If <em class="parameter"><code>signature</code></em> is not <code class="literal">NULL</code> but does not represent a valid GVariant type
string, <code class="literal">NULL</code> is returned and error is set to <code class="literal">G_IO_ERROR_INVALID_ARGUMENT</code>.
If a <em class="parameter"><code>signature</code></em> is provided but the JSON structure cannot be mapped to it,
<code class="literal">NULL</code> is returned and error is set to <code class="literal">G_IO_ERROR_INVALID_DATA</code>.
If <em class="parameter"><code>signature</code></em> is <code class="literal">NULL</code>, the conversion is done based strictly on the types
in the JSON nodes.
</p>
<p>
The returned variant has a floating reference that will need to be sunk
by the caller code.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>json_node</code></em> :</span></p></td>
<td>A <a class="link" href="json-glib-JSON-Node.html#JsonNode" title="JsonNode"><span class="type">JsonNode</span></a> to convert</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>signature</code></em> :</span></p></td>
<td>A valid <span class="type">GVariant</span> type string, or <code class="literal">NULL</code>. <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
<td>A pointer to a <span class="type">GError</span>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>A newly created, floating <span class="type">GVariant</span>
compliant with <em class="parameter"><code>signature</code></em>, or <code class="literal">NULL</code> on error. <span class="annotation">[<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>]</span>
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 0.14</p>
</div>
<hr>
<div class="refsect2">
<a name="json-gvariant-deserialize-data"></a><h3>json_gvariant_deserialize_data ()</h3>
<pre class="programlisting"><span class="returnvalue">GVariant</span> * json_gvariant_deserialize_data (<em class="parameter"><code>const <span class="type">gchar</span> *json</code></em>,
<em class="parameter"><code><span class="type">gssize</span> length</code></em>,
<em class="parameter"><code>const <span class="type">gchar</span> *signature</code></em>,
<em class="parameter"><code><span class="type">GError</span> **error</code></em>);</pre>
<p>
Converts a JSON string to a <span class="type">GVariant</span> value. This method works exactly
like <a class="link" href="json-glib-JSON-GVariant-Integration.html#json-gvariant-deserialize" title="json_gvariant_deserialize ()"><code class="function">json_gvariant_deserialize()</code></a>, but takes a JSON encoded string instead.
The string is first converted to a <a class="link" href="json-glib-JSON-Node.html#JsonNode" title="JsonNode"><span class="type">JsonNode</span></a> using <a class="link" href="JsonParser.html" title="JsonParser"><span class="type">JsonParser</span></a>, and then
<a class="link" href="json-glib-JSON-GVariant-Integration.html#json-gvariant-deserialize" title="json_gvariant_deserialize ()"><code class="function">json_gvariant_deserialize()</code></a> is called.
</p>
<p>
The returned variant has a floating reference that will need to be sunk
by the caller code.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>json</code></em> :</span></p></td>
<td>A JSON data string</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>length</code></em> :</span></p></td>
<td>The length of <em class="parameter"><code>json</code></em>, or -1 if <code class="literal">NULL</code>-terminated</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>signature</code></em> :</span></p></td>
<td>A valid <span class="type">GVariant</span> type string, or <code class="literal">NULL</code>. <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
<td>A pointer to a <span class="type">GError</span>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>A newly created, floating <span class="type">GVariant</span> compliant
with <em class="parameter"><code>signature</code></em>, or <code class="literal">NULL</code> on error. <span class="annotation">[<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>]</span>
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 0.14</p>
</div>
</div>
</div>
<div class="footer">
<hr>
Generated by GTK-Doc V1.19</div>
</body>
</html>
|