/usr/share/gtk-doc/html/json-glib/JsonReader.html is in libjson-glib-doc 0.14.2-1.
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 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JsonReader</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="index.html" title="JSON-GLib Reference Manual">
<link rel="up" href="ch02.html" title="Parser">
<link rel="prev" href="JsonParser.html" title="JsonParser">
<link rel="next" href="JsonPath.html" title="JsonPath">
<meta name="generator" content="GTK-Doc V1.18 (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="JsonParser.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="ch02.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="JsonPath.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts">
<a href="#JsonReader.synopsis" class="shortcut">Top</a>
|
<a href="#JsonReader.description" class="shortcut">Description</a>
|
<a href="#JsonReader.object-hierarchy" class="shortcut">Object Hierarchy</a>
|
<a href="#JsonReader.properties" class="shortcut">Properties</a>
</td></tr>
</table>
<div class="refentry">
<a name="JsonReader"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="JsonReader.top_of_page"></a>JsonReader</span></h2>
<p>JsonReader — A cursor-based parser</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<a name="JsonReader.synopsis"></a><h2>Synopsis</h2>
<pre class="synopsis">struct <a class="link" href="JsonReader.html#JsonReader-struct" title="struct JsonReader">JsonReader</a>;
struct <a class="link" href="JsonReader.html#JsonReaderClass" title="struct JsonReaderClass">JsonReaderClass</a>;
<a class="link" href="JsonReader.html" title="JsonReader"><span class="returnvalue">JsonReader</span></a> * <a class="link" href="JsonReader.html#json-reader-new" title="json_reader_new ()">json_reader_new</a> (<em class="parameter"><code><a class="link" href="json-glib-JSON-Node.html#JsonNode" title="JsonNode"><span class="type">JsonNode</span></a> *node</code></em>);
<span class="returnvalue">void</span> <a class="link" href="JsonReader.html#json-reader-set-root" title="json_reader_set_root ()">json_reader_set_root</a> (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>,
<em class="parameter"><code><a class="link" href="json-glib-JSON-Node.html#JsonNode" title="JsonNode"><span class="type">JsonNode</span></a> *root</code></em>);
<span class="returnvalue">gboolean</span> <a class="link" href="JsonReader.html#json-reader-read-element" title="json_reader_read_element ()">json_reader_read_element</a> (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>,
<em class="parameter"><code><span class="type">guint</span> index_</code></em>);
<span class="returnvalue">void</span> <a class="link" href="JsonReader.html#json-reader-end-element" title="json_reader_end_element ()">json_reader_end_element</a> (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>);
<span class="returnvalue">gboolean</span> <a class="link" href="JsonReader.html#json-reader-is-array" title="json_reader_is_array ()">json_reader_is_array</a> (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>);
<span class="returnvalue">gint</span> <a class="link" href="JsonReader.html#json-reader-count-elements" title="json_reader_count_elements ()">json_reader_count_elements</a> (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>);
<span class="returnvalue">gboolean</span> <a class="link" href="JsonReader.html#json-reader-read-member" title="json_reader_read_member ()">json_reader_read_member</a> (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>,
<em class="parameter"><code>const <span class="type">gchar</span> *member_name</code></em>);
<span class="returnvalue">void</span> <a class="link" href="JsonReader.html#json-reader-end-member" title="json_reader_end_member ()">json_reader_end_member</a> (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>);
<span class="returnvalue">gboolean</span> <a class="link" href="JsonReader.html#json-reader-is-object" title="json_reader_is_object ()">json_reader_is_object</a> (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>);
<span class="returnvalue">gint</span> <a class="link" href="JsonReader.html#json-reader-count-members" title="json_reader_count_members ()">json_reader_count_members</a> (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>);
<span class="returnvalue">gchar</span> ** <a class="link" href="JsonReader.html#json-reader-list-members" title="json_reader_list_members ()">json_reader_list_members</a> (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>);
const <span class="returnvalue">gchar</span> * <a class="link" href="JsonReader.html#json-reader-get-member-name" title="json_reader_get_member_name ()">json_reader_get_member_name</a> (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>);
<span class="returnvalue">gboolean</span> <a class="link" href="JsonReader.html#json-reader-is-value" title="json_reader_is_value ()">json_reader_is_value</a> (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>);
<a class="link" href="json-glib-JSON-Node.html#JsonNode" title="JsonNode"><span class="returnvalue">JsonNode</span></a> * <a class="link" href="JsonReader.html#json-reader-get-value" title="json_reader_get_value ()">json_reader_get_value</a> (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>);
<span class="returnvalue">gint64</span> <a class="link" href="JsonReader.html#json-reader-get-int-value" title="json_reader_get_int_value ()">json_reader_get_int_value</a> (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>);
<span class="returnvalue">gdouble</span> <a class="link" href="JsonReader.html#json-reader-get-double-value" title="json_reader_get_double_value ()">json_reader_get_double_value</a> (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>);
const <span class="returnvalue">gchar</span> * <a class="link" href="JsonReader.html#json-reader-get-string-value" title="json_reader_get_string_value ()">json_reader_get_string_value</a> (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>);
<span class="returnvalue">gboolean</span> <a class="link" href="JsonReader.html#json-reader-get-boolean-value" title="json_reader_get_boolean_value ()">json_reader_get_boolean_value</a> (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>);
<span class="returnvalue">gboolean</span> <a class="link" href="JsonReader.html#json-reader-get-null-value" title="json_reader_get_null_value ()">json_reader_get_null_value</a> (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>);
enum <a class="link" href="JsonReader.html#JsonReaderError" title="enum JsonReaderError">JsonReaderError</a>;
#define <a class="link" href="JsonReader.html#JSON-READER-ERROR:CAPS" title="JSON_READER_ERROR">JSON_READER_ERROR</a>
const <span class="returnvalue">GError</span> * <a class="link" href="JsonReader.html#json-reader-get-error" title="json_reader_get_error ()">json_reader_get_error</a> (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>);
</pre>
</div>
<div class="refsect1">
<a name="JsonReader.object-hierarchy"></a><h2>Object Hierarchy</h2>
<pre class="synopsis">
GObject
+----JsonReader
</pre>
</div>
<div class="refsect1">
<a name="JsonReader.properties"></a><h2>Properties</h2>
<pre class="synopsis">
"<a class="link" href="JsonReader.html#JsonReader--root" title='The "root" property'>root</a>" <a class="link" href="json-glib-JSON-Node.html#JsonNode" title="JsonNode"><span class="type">JsonNode</span></a>* : Read / Write / Construct
</pre>
</div>
<div class="refsect1">
<a name="JsonReader.description"></a><h2>Description</h2>
<p>
<a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> provides a simple, cursor-based API for parsing a JSON DOM. It
is similar, in spirit, to the XML Reader API.
</p>
<p>
In case of error, <a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> will be set in an error state; all subsequent
calls will simply be ignored until a function that resets the error state is
called, e.g.:
</p>
<p>
</p>
<div class="informalexample"><pre class="programlisting">
/* ask for the 7th element; if the element does not exist, the
* reader will be put in an error state
*/
json_reader_read_element (reader, 6);
/* in case of error, this will return NULL, otherwise it will
* return the value of the element
*/
str = json_reader_get_string_value (value);
/* this function resets the error state if any was set */
json_reader_end_element (reader);
</pre></div>
<p>
</p>
<p>
If you want to detect the error state as soon as possible, you can use
<a class="link" href="JsonReader.html#json-reader-get-error" title="json_reader_get_error ()"><code class="function">json_reader_get_error()</code></a>:
</p>
<p>
</p>
<div class="informalexample"><pre class="programlisting">
/* like the example above, but in this case we print out the
* error immediately
*/
if (!json_reader_read_element (reader, 6))
{
const GError *error = json_reader_get_error (reader);
g_print ("Unable to read the element: %s", error->message);
}
</pre></div>
<p>
</p>
<p>
<a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> is available since JSON-GLib 0.12.
</p>
</div>
<div class="refsect1">
<a name="JsonReader.details"></a><h2>Details</h2>
<div class="refsect2">
<a name="JsonReader-struct"></a><h3>struct JsonReader</h3>
<pre class="programlisting">struct JsonReader;</pre>
<p>
The <span class="structname">JsonReader</span> structure contains only
private data and should only be accessed using the provided API
</p>
<p class="since">Since 0.12</p>
</div>
<hr>
<div class="refsect2">
<a name="JsonReaderClass"></a><h3>struct JsonReaderClass</h3>
<pre class="programlisting">struct JsonReaderClass {
};
</pre>
<p>
The <span class="structname">JsonReaderClass</span> structure contains only
private data
</p>
<p class="since">Since 0.12</p>
</div>
<hr>
<div class="refsect2">
<a name="json-reader-new"></a><h3>json_reader_new ()</h3>
<pre class="programlisting"><a class="link" href="JsonReader.html" title="JsonReader"><span class="returnvalue">JsonReader</span></a> * json_reader_new (<em class="parameter"><code><a class="link" href="json-glib-JSON-Node.html#JsonNode" title="JsonNode"><span class="type">JsonNode</span></a> *node</code></em>);</pre>
<p>
Creates a new <a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a>. You can use this object to read the contents of
the JSON tree starting from <em class="parameter"><code>node</code></em>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>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>, 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"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the newly created <a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a>. Use <code class="function">g_object_unref()</code> to
release the allocated resources when done</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 0.12</p>
</div>
<hr>
<div class="refsect2">
<a name="json-reader-set-root"></a><h3>json_reader_set_root ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span> json_reader_set_root (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>,
<em class="parameter"><code><a class="link" href="json-glib-JSON-Node.html#JsonNode" title="JsonNode"><span class="type">JsonNode</span></a> *root</code></em>);</pre>
<p>
Sets the root <a class="link" href="json-glib-JSON-Node.html#JsonNode" title="JsonNode"><span class="type">JsonNode</span></a> to be read by <em class="parameter"><code>reader</code></em>. The <em class="parameter"><code>reader</code></em> will take
a copy of <em class="parameter"><code>root</code></em>
</p>
<p>
If another <a class="link" href="json-glib-JSON-Node.html#JsonNode" title="JsonNode"><span class="type">JsonNode</span></a> is currently set as root, it will be replaced.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>reader</code></em> :</span></p></td>
<td>a <a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>root</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>. <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 0.12</p>
</div>
<hr>
<div class="refsect2">
<a name="json-reader-read-element"></a><h3>json_reader_read_element ()</h3>
<pre class="programlisting"><span class="returnvalue">gboolean</span> json_reader_read_element (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>,
<em class="parameter"><code><span class="type">guint</span> index_</code></em>);</pre>
<p>
Advances the cursor of <em class="parameter"><code>reader</code></em> to the element <em class="parameter"><code>index_</code></em> of the array
or the object at the current position.
</p>
<p>
You can use the json_reader_get_value* family of functions to retrieve
the value of the element; for instance:
</p>
<p>
</p>
<div class="informalexample"><pre class="programlisting">
json_reader_read_element (reader, 0);
int_value = json_reader_get_int_value (reader);
</pre></div>
<p>
</p>
<p>
After reading the value, <a class="link" href="JsonReader.html#json-reader-end-element" title="json_reader_end_element ()"><code class="function">json_reader_end_element()</code></a> should be called to
reposition the cursor inside the <a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a>, e.g.:
</p>
<p>
</p>
<div class="informalexample"><pre class="programlisting">
json_reader_read_element (reader, 1);
str_value = json_reader_get_string_value (reader);
json_reader_end_element (reader);
json_reader_read_element (reader, 2);
str_value = json_reader_get_string_value (reader);
json_reader_end_element (reader);
</pre></div>
<p>
</p>
<p>
If <em class="parameter"><code>reader</code></em> is not currently on an array or an object, or if the <em class="parameter"><code>index_</code></em> is
bigger than the size of the array or the object, the <a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> will be
put in an error state until <a class="link" href="JsonReader.html#json-reader-end-element" title="json_reader_end_element ()"><code class="function">json_reader_end_element()</code></a> is called.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>reader</code></em> :</span></p></td>
<td>a <a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>index_</code></em> :</span></p></td>
<td>the index of the element</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>
<code class="literal">TRUE</code> on success, and <code class="literal">FALSE</code> otherwise</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 0.12</p>
</div>
<hr>
<div class="refsect2">
<a name="json-reader-end-element"></a><h3>json_reader_end_element ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span> json_reader_end_element (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>);</pre>
<p>
Moves the cursor back to the previous node after being positioned
inside an array
</p>
<p>
This function resets the error state of <em class="parameter"><code>reader</code></em>, if any was set
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>reader</code></em> :</span></p></td>
<td>a <a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a>
</td>
</tr></tbody>
</table></div>
<p class="since">Since 0.12</p>
</div>
<hr>
<div class="refsect2">
<a name="json-reader-is-array"></a><h3>json_reader_is_array ()</h3>
<pre class="programlisting"><span class="returnvalue">gboolean</span> json_reader_is_array (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>);</pre>
<p>
Checks whether the <em class="parameter"><code>reader</code></em> is currently on an array
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>reader</code></em> :</span></p></td>
<td>a <a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>
<code class="literal">TRUE</code> if the <a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> is on an array, and <code class="literal">FALSE</code>
otherwise</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 0.12</p>
</div>
<hr>
<div class="refsect2">
<a name="json-reader-count-elements"></a><h3>json_reader_count_elements ()</h3>
<pre class="programlisting"><span class="returnvalue">gint</span> json_reader_count_elements (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>);</pre>
<p>
Counts the elements of the current position, if <em class="parameter"><code>reader</code></em> is
positioned on an array
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>reader</code></em> :</span></p></td>
<td>a <a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the number of elements, or -1. In case of failure
the <a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> is set in an error state</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 0.12</p>
</div>
<hr>
<div class="refsect2">
<a name="json-reader-read-member"></a><h3>json_reader_read_member ()</h3>
<pre class="programlisting"><span class="returnvalue">gboolean</span> json_reader_read_member (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>,
<em class="parameter"><code>const <span class="type">gchar</span> *member_name</code></em>);</pre>
<p>
Advances the cursor of <em class="parameter"><code>reader</code></em> to the <em class="parameter"><code>member_name</code></em> of the object at the
current position.
</p>
<p>
You can use the json_reader_get_value* family of functions to retrieve
the value of the member; for instance:
</p>
<p>
</p>
<div class="informalexample"><pre class="programlisting">
json_reader_read_member (reader, "width");
width = json_reader_get_int_value (reader);
</pre></div>
<p>
</p>
<p>
After reading the value, <a class="link" href="JsonReader.html#json-reader-end-member" title="json_reader_end_member ()"><code class="function">json_reader_end_member()</code></a> should be called to
reposition the cursor inside the <a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a>, e.g.:
</p>
<p>
</p>
<div class="informalexample"><pre class="programlisting">
json_reader_read_member (reader, "author");
author = json_reader_get_string_value (reader);
json_reader_end_element (reader);
json_reader_read_element (reader, "title");
title = json_reader_get_string_value (reader);
json_reader_end_element (reader);
</pre></div>
<p>
</p>
<p>
If <em class="parameter"><code>reader</code></em> is not currently on an object, or if the <em class="parameter"><code>member_name</code></em> is not
defined in the object, the <a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> will be put in an error state until
<a class="link" href="JsonReader.html#json-reader-end-member" title="json_reader_end_member ()"><code class="function">json_reader_end_member()</code></a> is called.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>reader</code></em> :</span></p></td>
<td>a <a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>member_name</code></em> :</span></p></td>
<td>the name of the member to read</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>
<code class="literal">TRUE</code> on success, and <code class="literal">FALSE</code> otherwise</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 0.12</p>
</div>
<hr>
<div class="refsect2">
<a name="json-reader-end-member"></a><h3>json_reader_end_member ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span> json_reader_end_member (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>);</pre>
<p>
Moves the cursor back to the previous node after being positioned
inside an object
</p>
<p>
This function resets the error state of <em class="parameter"><code>reader</code></em>, if any was set
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>reader</code></em> :</span></p></td>
<td>a <a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a>
</td>
</tr></tbody>
</table></div>
<p class="since">Since 0.12</p>
</div>
<hr>
<div class="refsect2">
<a name="json-reader-is-object"></a><h3>json_reader_is_object ()</h3>
<pre class="programlisting"><span class="returnvalue">gboolean</span> json_reader_is_object (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>);</pre>
<p>
Checks whether the <em class="parameter"><code>reader</code></em> is currently on an object
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>reader</code></em> :</span></p></td>
<td>a <a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>
<code class="literal">TRUE</code> if the <a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> is on an object, and <code class="literal">FALSE</code>
otherwise</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 0.12</p>
</div>
<hr>
<div class="refsect2">
<a name="json-reader-count-members"></a><h3>json_reader_count_members ()</h3>
<pre class="programlisting"><span class="returnvalue">gint</span> json_reader_count_members (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>);</pre>
<p>
Counts the members of the current position, if <em class="parameter"><code>reader</code></em> is
positioned on an object
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>reader</code></em> :</span></p></td>
<td>a <a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the number of members, or -1. In case of failure
the <a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> is set in an error state</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 0.12</p>
</div>
<hr>
<div class="refsect2">
<a name="json-reader-list-members"></a><h3>json_reader_list_members ()</h3>
<pre class="programlisting"><span class="returnvalue">gchar</span> ** json_reader_list_members (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>);</pre>
<p>
Retrieves a list of member names from the current position, if <em class="parameter"><code>reader</code></em>
is positioned on an object.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>reader</code></em> :</span></p></td>
<td>a <a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>a newly allocated, <code class="literal">NULL</code>-terminated
array of strings holding the members name. Use <code class="function">g_strfreev()</code> when
done. <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-reader-get-member-name"></a><h3>json_reader_get_member_name ()</h3>
<pre class="programlisting">const <span class="returnvalue">gchar</span> * json_reader_get_member_name (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>);</pre>
<p>
Retrieves the name of the current member.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>reader</code></em> :</span></p></td>
<td>a <a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the name of the member, or <code class="literal">NULL</code>. <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-reader-is-value"></a><h3>json_reader_is_value ()</h3>
<pre class="programlisting"><span class="returnvalue">gboolean</span> json_reader_is_value (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>);</pre>
<p>
Checks whether the <em class="parameter"><code>reader</code></em> is currently on a value
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>reader</code></em> :</span></p></td>
<td>a <a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>
<code class="literal">TRUE</code> if the <a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> is on a value, and <code class="literal">FALSE</code>
otherwise</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 0.12</p>
</div>
<hr>
<div class="refsect2">
<a name="json-reader-get-value"></a><h3>json_reader_get_value ()</h3>
<pre class="programlisting"><a class="link" href="json-glib-JSON-Node.html#JsonNode" title="JsonNode"><span class="returnvalue">JsonNode</span></a> * json_reader_get_value (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>);</pre>
<p>
Retrieves the <a class="link" href="json-glib-JSON-Node.html#JsonNode" title="JsonNode"><span class="type">JsonNode</span></a> of the current position of <em class="parameter"><code>reader</code></em>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>reader</code></em> :</span></p></td>
<td>a <a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a>
</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>, or <code class="literal">NULL</code>. The returned node
is owned by the <a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> and it should not be modified or freed
directly. <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.12</p>
</div>
<hr>
<div class="refsect2">
<a name="json-reader-get-int-value"></a><h3>json_reader_get_int_value ()</h3>
<pre class="programlisting"><span class="returnvalue">gint64</span> json_reader_get_int_value (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>);</pre>
<p>
Retrieves the integer value of the current position of <em class="parameter"><code>reader</code></em>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>reader</code></em> :</span></p></td>
<td>a <a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the integer value</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 0.12</p>
</div>
<hr>
<div class="refsect2">
<a name="json-reader-get-double-value"></a><h3>json_reader_get_double_value ()</h3>
<pre class="programlisting"><span class="returnvalue">gdouble</span> json_reader_get_double_value (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>);</pre>
<p>
Retrieves the floating point value of the current position of <em class="parameter"><code>reader</code></em>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>reader</code></em> :</span></p></td>
<td>a <a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the floating point value</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 0.12</p>
</div>
<hr>
<div class="refsect2">
<a name="json-reader-get-string-value"></a><h3>json_reader_get_string_value ()</h3>
<pre class="programlisting">const <span class="returnvalue">gchar</span> * json_reader_get_string_value (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>);</pre>
<p>
Retrieves the string value of the current position of <em class="parameter"><code>reader</code></em>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>reader</code></em> :</span></p></td>
<td>a <a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the string value</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 0.12</p>
</div>
<hr>
<div class="refsect2">
<a name="json-reader-get-boolean-value"></a><h3>json_reader_get_boolean_value ()</h3>
<pre class="programlisting"><span class="returnvalue">gboolean</span> json_reader_get_boolean_value (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>);</pre>
<p>
Retrieves the boolean value of the current position of <em class="parameter"><code>reader</code></em>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>reader</code></em> :</span></p></td>
<td>a <a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the boolean value</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 0.12</p>
</div>
<hr>
<div class="refsect2">
<a name="json-reader-get-null-value"></a><h3>json_reader_get_null_value ()</h3>
<pre class="programlisting"><span class="returnvalue">gboolean</span> json_reader_get_null_value (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>);</pre>
<p>
Checks whether the value of the current position of <em class="parameter"><code>reader</code></em> is 'null'
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>reader</code></em> :</span></p></td>
<td>a <a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>
<code class="literal">TRUE</code> if 'null' is set, and <code class="literal">FALSE</code> otherwise</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 0.12</p>
</div>
<hr>
<div class="refsect2">
<a name="JsonReaderError"></a><h3>enum JsonReaderError</h3>
<pre class="programlisting">typedef enum {
JSON_READER_ERROR_NO_ARRAY,
JSON_READER_ERROR_INVALID_INDEX,
JSON_READER_ERROR_NO_OBJECT,
JSON_READER_ERROR_INVALID_MEMBER,
JSON_READER_ERROR_INVALID_NODE,
JSON_READER_ERROR_NO_VALUE,
JSON_READER_ERROR_INVALID_TYPE
} JsonReaderError;
</pre>
<p>
Error codes enumeration for <a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> errors
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><a name="JSON-READER-ERROR-NO-ARRAY:CAPS"></a><span class="term"><code class="literal">JSON_READER_ERROR_NO_ARRAY</code></span></p></td>
<td>No array found at the current position
</td>
</tr>
<tr>
<td><p><a name="JSON-READER-ERROR-INVALID-INDEX:CAPS"></a><span class="term"><code class="literal">JSON_READER_ERROR_INVALID_INDEX</code></span></p></td>
<td>Index out of bounds
</td>
</tr>
<tr>
<td><p><a name="JSON-READER-ERROR-NO-OBJECT:CAPS"></a><span class="term"><code class="literal">JSON_READER_ERROR_NO_OBJECT</code></span></p></td>
<td>No object found at the current position
</td>
</tr>
<tr>
<td><p><a name="JSON-READER-ERROR-INVALID-MEMBER:CAPS"></a><span class="term"><code class="literal">JSON_READER_ERROR_INVALID_MEMBER</code></span></p></td>
<td>Member not found
</td>
</tr>
<tr>
<td><p><a name="JSON-READER-ERROR-INVALID-NODE:CAPS"></a><span class="term"><code class="literal">JSON_READER_ERROR_INVALID_NODE</code></span></p></td>
<td>No valid node found at the current position
</td>
</tr>
<tr>
<td><p><a name="JSON-READER-ERROR-NO-VALUE:CAPS"></a><span class="term"><code class="literal">JSON_READER_ERROR_NO_VALUE</code></span></p></td>
<td>The node at the current position does not
hold a value
</td>
</tr>
<tr>
<td><p><a name="JSON-READER-ERROR-INVALID-TYPE:CAPS"></a><span class="term"><code class="literal">JSON_READER_ERROR_INVALID_TYPE</code></span></p></td>
<td>The node at the current position does not
hold a value of the desired type
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 0.12</p>
</div>
<hr>
<div class="refsect2">
<a name="JSON-READER-ERROR:CAPS"></a><h3>JSON_READER_ERROR</h3>
<pre class="programlisting">#define JSON_READER_ERROR (json_reader_error_quark ())
</pre>
<p>
Error domain for <a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> errors
</p>
<p class="since">Since 0.12</p>
</div>
<hr>
<div class="refsect2">
<a name="json-reader-get-error"></a><h3>json_reader_get_error ()</h3>
<pre class="programlisting">const <span class="returnvalue">GError</span> * json_reader_get_error (<em class="parameter"><code><a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> *reader</code></em>);</pre>
<p>
Retrieves the <span class="type">GError</span> currently set on <em class="parameter"><code>reader</code></em>, if the <a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a>
is in error state
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>reader</code></em> :</span></p></td>
<td>a <a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the pointer to the error, or <code class="literal">NULL</code>. <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.12</p>
</div>
</div>
<div class="refsect1">
<a name="JsonReader.property-details"></a><h2>Property Details</h2>
<div class="refsect2">
<a name="JsonReader--root"></a><h3>The <code class="literal">"root"</code> property</h3>
<pre class="programlisting"> "root" <a class="link" href="json-glib-JSON-Node.html#JsonNode" title="JsonNode"><span class="type">JsonNode</span></a>* : Read / Write / Construct</pre>
<p>
The root of the JSON tree that the <a class="link" href="JsonReader.html" title="JsonReader"><span class="type">JsonReader</span></a> should read.
</p>
<p class="since">Since 0.12</p>
</div>
</div>
</div>
<div class="footer">
<hr>
Generated by GTK-Doc V1.18</div>
</body>
</html>
|