/usr/share/gtk-doc/html/json-glib/json-glib-JSON-GVariant-Integration.html is in libjson-glib-doc 1.1.2-0ubuntu1.
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 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | <!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: JSON-GLib Reference Manual</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.79.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-glib-Versioning-information.html" title="Versioning information">
<meta name="generator" content="GTK-Doc V1.24 (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="5"><tr valign="middle">
<td width="100%" align="left" class="shortcuts">
<a href="#" class="shortcut">Top</a><span id="nav_description"> <span class="dim">|</span>
<a href="#json-glib-JSON-GVariant-Integration.description" class="shortcut">Description</a></span>
</td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
<td><a accesskey="u" href="json-advanced.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
<td><a accesskey="p" href="json-glib-Boxed-Types-Serialization.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="json-glib-Versioning-information.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></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 class="gallery_image" valign="top" align="right"></td>
</tr></table></div>
<div class="refsect1">
<a name="json-glib-JSON-GVariant-Integration.functions"></a><h2>Functions</h2>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="functions_return">
<col class="functions_name">
</colgroup>
<tbody>
<tr>
<td class="function_type">
<a class="link" href="json-glib-JSON-Node.html#JsonNode"><span class="returnvalue">JsonNode</span></a> *
</td>
<td class="function_name">
<a class="link" href="json-glib-JSON-GVariant-Integration.html#json-gvariant-serialize" title="json_gvariant_serialize ()">json_gvariant_serialize</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">gchar</span> *
</td>
<td class="function_name">
<a class="link" href="json-glib-JSON-GVariant-Integration.html#json-gvariant-serialize-data" title="json_gvariant_serialize_data ()">json_gvariant_serialize_data</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">GVariant</span> *
</td>
<td class="function_name">
<a class="link" href="json-glib-JSON-GVariant-Integration.html#json-gvariant-deserialize" title="json_gvariant_deserialize ()">json_gvariant_deserialize</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">GVariant</span> *
</td>
<td class="function_name">
<a class="link" href="json-glib-JSON-GVariant-Integration.html#json-gvariant-deserialize-data" title="json_gvariant_deserialize_data ()">json_gvariant_deserialize_data</a> <span class="c_punctuation">()</span>
</td>
</tr>
</tbody>
</table></div>
</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"><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"><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
using the following rules:</p>
<div class="refsect3">
<a name="id-1.5.5.4.5"></a><h4>Strings</h4>
<p>JSON strings map to GVariant <code class="literal">(s)</code>.</p>
</div>
<div class="refsect3">
<a name="id-1.5.5.4.6"></a><h4>Integers</h4>
<p>JSON integers map to GVariant int64 <code class="literal">(x)</code>.</p>
</div>
<div class="refsect3">
<a name="id-1.5.5.4.7"></a><h4>Booleans</h4>
<p>JSON booleans map to GVariant boolean <code class="literal">(b)</code>.</p>
</div>
<div class="refsect3">
<a name="id-1.5.5.4.8"></a><h4>Numbers</h4>
<p>JSON numbers map to GVariant double <code class="literal">(d)</code>.</p>
</div>
<div class="refsect3">
<a name="id-1.5.5.4.9"></a><h4>Arrays</h4>
<p>JSON arrays map to GVariant arrays of variants <code class="literal">(av)</code>.</p>
</div>
<div class="refsect3">
<a name="id-1.5.5.4.10"></a><h4>Objects</h4>
<p>JSON objects map to GVariant dictionaries of string to variants <code class="literal">(a{sv})</code>.</p>
</div>
<div class="refsect3">
<a name="id-1.5.5.4.11"></a><h4>Null values</h4>
<p>JSON null values map to GVariant maybe variants <code class="literal">(mv)</code>.</p>
</div>
</div>
<div class="refsect1">
<a name="json-glib-JSON-GVariant-Integration.functions_details"></a><h2>Functions</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"><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="refsect3">
<a name="id-1.5.5.5.2.5"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>variant</p></td>
<td class="parameter_description"><p>A <span class="type">GVariant</span> to convert</p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.5.5.2.6"></a><h4>Returns</h4>
<p> A <a class="link" href="json-glib-JSON-Node.html#JsonNode"><span class="type">JsonNode</span></a> representing the root of the
JSON data structure obtained from <em class="parameter"><code>variant</code></em>
. </p>
<p><span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span></p>
</div>
<p class="since">Since: <a class="link" href="ix08.html#api-index-0.14">0.14</a></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="refsect3">
<a name="id-1.5.5.5.3.5"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>variant</p></td>
<td class="parameter_description"><p>A <span class="type">GVariant</span> to convert</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>length</p></td>
<td class="parameter_description"><p> Return location for the length of the returned
string, or <code class="literal">NULL</code>. </p></td>
<td class="parameter_annotations"><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>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.5.5.3.6"></a><h4>Returns</h4>
<p> The JSON encoded string corresponding to
<em class="parameter"><code>variant</code></em>
. </p>
<p><span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span></p>
</div>
<p class="since">Since: <a class="link" href="ix08.html#api-index-0.14">0.14</a></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"><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="refsect3">
<a name="id-1.5.5.5.4.7"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>json_node</p></td>
<td class="parameter_description"><p>A <a class="link" href="json-glib-JSON-Node.html#JsonNode"><span class="type">JsonNode</span></a> to convert</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>signature</p></td>
<td class="parameter_description"><p> A valid <span class="type">GVariant</span> type string, or <code class="literal">NULL</code>. </p></td>
<td class="parameter_annotations"><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 class="parameter_name"><p>error</p></td>
<td class="parameter_description"><p>A pointer to a <span class="type">GError</span></p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.5.5.4.8"></a><h4>Returns</h4>
<p> 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. </p>
<p><span class="annotation">[<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>]</span></p>
</div>
<p class="since">Since: <a class="link" href="ix08.html#api-index-0.14">0.14</a></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"><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="refsect3">
<a name="id-1.5.5.5.5.6"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>json</p></td>
<td class="parameter_description"><p>A JSON data string</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>length</p></td>
<td class="parameter_description"><p>The length of <em class="parameter"><code>json</code></em>
, or -1 if <code class="literal">NULL</code>-terminated</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>signature</p></td>
<td class="parameter_description"><p> A valid <span class="type">GVariant</span> type string, or <code class="literal">NULL</code>. </p></td>
<td class="parameter_annotations"><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 class="parameter_name"><p>error</p></td>
<td class="parameter_description"><p>A pointer to a <span class="type">GError</span></p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.5.5.5.5.7"></a><h4>Returns</h4>
<p> 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. </p>
<p><span class="annotation">[<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>]</span></p>
</div>
<p class="since">Since: <a class="link" href="ix08.html#api-index-0.14">0.14</a></p>
</div>
</div>
<div class="refsect1">
<a name="json-glib-JSON-GVariant-Integration.other_details"></a><h2>Types and Values</h2>
</div>
</div>
<div class="footer">
<hr>Generated by GTK-Doc V1.24</div>
</body>
</html>
|