2 // Automatically generated from "/usr/share/gir-1.0/Json-1.0.gir"
5 public import gtk2
.glib2
;
6 alias gtk2
.glib2 GLib2
;
7 public import gtk2
.gobject2
;
8 alias gtk2
.gobject2 GObject2
;
9 public import gtk2
.gio2
;
12 // package: "json-glib-1.0";
13 // C header: "json-glib/json-glib.h";
15 // c:symbol-prefixes: ["json"]
16 // c:identifier-prefixes: ["Json"]
21 // A JSON array type. The contents of the #JsonArray structure are private
22 // and should only be accessed by the provided API
25 // Creates a new #JsonArray.
26 // RETURNS: the newly created #JsonArray
27 static Array
* /*new*/ new_() {
28 return json_array_new();
31 // Creates a new #JsonArray with @n_elements slots already allocated.
32 // RETURNS: the newly created #JsonArray
33 // <n_elements>: number of slots to pre-allocate
34 static Array
* /*new*/ sized_new(uint n_elements
) {
35 return json_array_sized_new(n_elements
);
38 // Conveniently adds an array into @array. The @array takes ownership
39 // of the newly added #JsonArray
41 // See also: json_array_add_element(), json_node_take_array()
42 // <value>: a #JsonArray
43 void add_array_element(Array
* value
) {
44 json_array_add_array_element(&this, value
);
47 // Conveniently adds a boolean @value into @array
49 // See also: json_array_add_element(), json_node_set_boolean()
50 // <value>: a boolean value
51 void add_boolean_element(int value
) {
52 json_array_add_boolean_element(&this, value
);
55 // Conveniently adds a floating point @value into @array
57 // See also: json_array_add_element(), json_node_set_double()
58 // <value>: a floating point value
59 void add_double_element(double value
) {
60 json_array_add_double_element(&this, value
);
63 // Appends @node inside @array. The array will take ownership of the
65 // <node>: a #JsonNode
66 void add_element(Node
* node
) {
67 json_array_add_element(&this, node
);
70 // Conveniently adds an integer @value into @array
72 // See also: json_array_add_element(), json_node_set_int()
73 // <value>: an integer value
74 void add_int_element(long value
) {
75 json_array_add_int_element(&this, value
);
78 // Conveniently adds a null element into @array
80 // See also: json_array_add_element(), %JSON_NODE_NULL
81 void add_null_element() {
82 json_array_add_null_element(&this);
85 // Conveniently adds an object into @array. The @array takes ownership
86 // of the newly added #JsonObject
88 // See also: json_array_add_element(), json_node_take_object()
89 // <value>: a #JsonObject
90 void add_object_element(Object
* value
) {
91 json_array_add_object_element(&this, value
);
94 // Conveniently adds a string @value into @array
96 // See also: json_array_add_element(), json_node_set_string()
97 // <value>: a string value
98 void add_string_element(char* value
) {
99 json_array_add_string_element(&this, value
);
102 // Retrieves a copy of the #JsonNode containing the value of the
103 // element at @index_ inside a #JsonArray
105 // index. Use json_node_free() when done.
106 // RETURNS: a copy of the #JsonNode at the requested
107 // <index_>: the index of the element to retrieve
108 Node
* /*new*/ dup_element(uint index_
) {
109 return json_array_dup_element(&this, index_
);
112 // Iterates over all elements of @array and calls @func on
115 // It is safe to change the value of a #JsonNode of the @array
116 // from within the iterator @func, but it is not safe to add or
117 // remove elements from the @array.
118 // <func>: the function to be called on each element
119 // <data>: data to be passed to the function
120 void foreach_element(ArrayForeach func
, void* data
) {
121 json_array_foreach_element(&this, func
, data
);
124 // Conveniently retrieves the array from the element at @index_
127 // See also: json_array_get_element(), json_node_get_array()
128 // RETURNS: the array
129 // <index_>: the index of the element to retrieve
130 Array
* get_array_element(uint index_
) {
131 return json_array_get_array_element(&this, index_
);
134 // Conveniently retrieves the boolean value of the element at @index_
137 // See also: json_array_get_element(), json_node_get_boolean()
138 // RETURNS: the integer value
139 // <index_>: the index of the element to retrieve
140 int get_boolean_element(uint index_
) {
141 return json_array_get_boolean_element(&this, index_
);
144 // Conveniently retrieves the floating point value of the element at
145 // @index_ inside @array
147 // See also: json_array_get_element(), json_node_get_double()
148 // RETURNS: the floating point value
149 // <index_>: the index of the element to retrieve
150 double get_double_element(uint index_
) {
151 return json_array_get_double_element(&this, index_
);
154 // Retrieves the #JsonNode containing the value of the element at @index_
155 // inside a #JsonArray.
156 // RETURNS: a pointer to the #JsonNode at the requested index
157 // <index_>: the index of the element to retrieve
158 Node
* get_element(uint index_
) {
159 return json_array_get_element(&this, index_
);
162 // Gets the elements of a #JsonArray as a list of #JsonNode<!-- -->s.
164 // containing the elements of the array. The contents of the list are
165 // owned by the array and should never be modified or freed. Use
166 // g_list_free() on the returned list when done using it
168 GLib2
.List
* /*new container*/ get_elements() {
169 return json_array_get_elements(&this);
172 // Conveniently retrieves the integer value of the element at @index_
175 // See also: json_array_get_element(), json_node_get_int()
176 // RETURNS: the integer value
177 // <index_>: the index of the element to retrieve
178 long get_int_element(uint index_
) {
179 return json_array_get_int_element(&this, index_
);
182 // Retrieves the length of a #JsonArray
183 // RETURNS: the length of the array
185 return json_array_get_length(&this);
188 // Conveniently retrieves whether the element at @index_ is set to null
190 // See also: json_array_get_element(), JSON_NODE_TYPE(), %JSON_NODE_NULL
191 // RETURNS: %TRUE if the element is null
192 // <index_>: the index of the element to retrieve
193 int get_null_element(uint index_
) {
194 return json_array_get_null_element(&this, index_
);
197 // Conveniently retrieves the object from the element at @index_
200 // See also: json_array_get_element(), json_node_get_object()
201 // RETURNS: the object
202 // <index_>: the index of the element to retrieve
203 Object
* get_object_element(uint index_
) {
204 return json_array_get_object_element(&this, index_
);
207 // Conveniently retrieves the string value of the element at @index_
210 // See also: json_array_get_element(), json_node_get_string()
212 // the #JsonArray and should not be modified or freed
213 // RETURNS: the string value; the returned string is owned by
214 // <index_>: the index of the element to retrieve
215 char* get_string_element(uint index_
) {
216 return json_array_get_string_element(&this, index_
);
219 // Increase by one the reference count of a #JsonArray.
222 // RETURNS: the passed #JsonArray, with the reference count
223 Array
* /*new*/ ref_() {
224 return json_array_ref(&this);
227 // Removes the #JsonNode inside @array at @index_ freeing its allocated
229 // <index_>: the position of the element to be removed
230 void remove_element(uint index_
) {
231 json_array_remove_element(&this, index_
);
234 // Decreases by one the reference count of a #JsonArray. If the
235 // reference count reaches zero, the array is destroyed and all
236 // its allocated resources are freed.
238 json_array_unref(&this);
243 // The function to be passed to json_array_foreach_element(). You
244 // should not add or remove elements to and from @array within
245 // this function. It is safe to change the value of @element_node.
246 // <array>: the iterated #JsonArray
247 // <index_>: the index of the element
248 // <element_node>: a #JsonNode containing the value at @index_
249 // <user_data>: data passed to the function
250 extern (C
) alias void function (Array
* array
, uint index_
, Node
* element_node
, void* user_data
) ArrayForeach
;
253 // Unintrospectable callback: BoxedDeserializeFunc() / ()
254 // Deserializes the contents of the passed #JsonNode into a #GBoxed
255 // RETURNS: the newly created boxed type
256 // <node>: a #JsonNode
257 extern (C
) alias void* function (Node
* node
) BoxedDeserializeFunc
;
260 // Serializes the passed #GBoxed and stores it inside a #JsonNode
261 // RETURNS: the newly created #JsonNode
262 // <boxed>: a #GBoxed
263 extern (C
) alias Node
* /*new*/ function (const(void)* boxed
) BoxedSerializeFunc
;
266 // The <structname>JsonBuilder</structname> structure contains only
267 // private data and shouls be accessed using the provided API
268 struct Builder
/* : GObject.Object */ /* Version 0.12 */ {
269 alias parent_instance
this;
270 alias parent_instance super_
;
271 alias parent_instance object
;
272 GObject2
.Object parent_instance
;
273 private BuilderPrivate
* priv
;
276 // Creates a new #JsonBuilder. You can use this object to generate a
277 // JSON tree and obtain the root #JsonNode<!-- -->s.
278 // RETURNS: the newly created #JsonBuilder instance
279 static Builder
* /*new*/ new_() {
280 return json_builder_new();
283 // If called after json_builder_set_member_name(), sets @value as member of the
284 // most recent opened object, otherwise @value is added as element of the most
285 // recent opened array.
287 // See also: json_builder_add_value()
288 // RETURNS: the #JsonBuilder, or %NULL if the call was inconsistent
289 // <value>: the value of the member or element
290 Builder
* add_boolean_value(int value
) {
291 return json_builder_add_boolean_value(&this, value
);
294 // If called after json_builder_set_member_name(), sets @value as member of the
295 // most recent opened object, otherwise @value is added as element of the most
296 // recent opened array.
298 // See also: json_builder_add_value()
299 // RETURNS: the #JsonBuilder, or %NULL if the call was inconsistent
300 // <value>: the value of the member or element
301 Builder
* add_double_value(double value
) {
302 return json_builder_add_double_value(&this, value
);
305 // If called after json_builder_set_member_name(), sets @value as member of the
306 // most recent opened object, otherwise @value is added as element of the most
307 // recent opened array.
309 // See also: json_builder_add_value()
310 // RETURNS: the #JsonBuilder, or %NULL if the call was inconsistent
311 // <value>: the value of the member or element
312 Builder
* add_int_value(long value
) {
313 return json_builder_add_int_value(&this, value
);
316 // If called after json_builder_set_member_name(), sets null as member of the
317 // most recent opened object, otherwise null is added as element of the most
318 // recent opened array.
320 // See also: json_builder_add_value()
321 // RETURNS: the #JsonBuilder, or %NULL if the call was inconsistent
322 Builder
* add_null_value() {
323 return json_builder_add_null_value(&this);
326 // If called after json_builder_set_member_name(), sets @value as member of the
327 // most recent opened object, otherwise @value is added as element of the most
328 // recent opened array.
330 // See also: json_builder_add_value()
331 // RETURNS: the #JsonBuilder, or %NULL if the call was inconsistent
332 // <value>: the value of the member or element
333 Builder
* add_string_value(char* value
) {
334 return json_builder_add_string_value(&this, value
);
337 // If called after json_builder_set_member_name(), sets @node as member of the
338 // most recent opened object, otherwise @node is added as element of the most
339 // recent opened array.
340 // RETURNS: the #JsonBuilder, or %NULL if the call was inconsistent
341 // <node>: the value of the member or element
342 Builder
* add_value(Node
* node
) {
343 return json_builder_add_value(&this, node
);
346 // Opens a subarray inside the given @builder. When done adding members to
347 // the subarray, json_builder_end_array() must be called.
349 // Can be called for first or only if the call is associated to an object member
350 // or an array element.
351 // RETURNS: the #JsonBuilder, or %NULL if the call was inconsistent
352 Builder
* begin_array() {
353 return json_builder_begin_array(&this);
356 // Opens a subobject inside the given @builder. When done adding members to
357 // the subobject, json_builder_end_object() must be called.
359 // Can be called for first or only if the call is associated to an object member
360 // or an array element.
361 // RETURNS: the #JsonBuilder, or %NULL if the call was inconsistent
362 Builder
* begin_object() {
363 return json_builder_begin_object(&this);
366 // Closes the subarray inside the given @builder that was opened by the most
367 // recent call to json_builder_begin_array().
369 // Cannot be called after json_builder_set_member_name().
370 // RETURNS: the #JsonBuilder, or %NULL if the call was inconsistent
371 Builder
* end_array() {
372 return json_builder_end_array(&this);
375 // Closes the subobject inside the given @builder that was opened by the most
376 // recent call to json_builder_begin_object().
378 // Cannot be called after json_builder_set_member_name().
379 // RETURNS: the #JsonBuilder, or %NULL if the call was inconsistent
380 Builder
* end_object() {
381 return json_builder_end_object(&this);
384 // Returns the root of the current constructed tree, if the build is complete
385 // (ie: all opened objects, object members and arrays are being closed).
387 // Free the returned value with json_node_free().
388 // RETURNS: the #JsonNode, or %NULL if the build is not complete.
389 Node
* /*new*/ get_root() {
390 return json_builder_get_root(&this);
392 // Resets the state of the @builder back to its initial state.
394 json_builder_reset(&this);
397 // Set the name of the next member in an object. The next call must add a value,
398 // open an object or an array.
400 // Can be called only if the call is associated to an object.
401 // RETURNS: the #JsonBuilder, or %NULL if the call was inconsistent
402 // <member_name>: the name of the member
403 Builder
* set_member_name(char* member_name
) {
404 return json_builder_set_member_name(&this, member_name
);
409 // The <structname>JsonBuilder</structname> structure contains only
411 struct BuilderClass
/* Version 0.12 */ {
412 private GObject2
.ObjectClass parent_class
;
413 extern (C
) void function () _json_reserved1
;
414 extern (C
) void function () _json_reserved2
;
417 struct BuilderPrivate
{
421 // JSON data streams generator. The contents of the #JsonGenerator structure
422 // are private and should only be accessed via the provided API.
423 struct Generator
/* : GObject.Object */ {
424 alias parent_instance
this;
425 alias parent_instance super_
;
426 alias parent_instance object
;
427 GObject2
.Object parent_instance
;
428 private GeneratorPrivate
* priv
;
431 // Creates a new #JsonGenerator. You can use this object to generate a
432 // JSON data stream starting from a data object model composed by
433 // #JsonNode<!-- -->s.
434 // RETURNS: the newly created #JsonGenerator instance
435 static Generator
* /*new*/ new_() {
436 return json_generator_new();
439 // Retrieves the value set using json_generator_set_indent().
440 // RETURNS: the number of repetitions per indentation level
442 return json_generator_get_indent(&this);
445 // Retrieves the value set using json_generator_set_indent_char().
446 // RETURNS: the character to be used when indenting
447 dchar get_indent_char() {
448 return json_generator_get_indent_char(&this);
451 // Retrieves the value set using json_generator_set_pretty().
454 // RETURNS: %TRUE if the generated JSON should be pretty-printed, and
456 return json_generator_get_pretty(&this);
459 // Retrieves a pointer to the root #JsonNode set using
460 // json_generator_set_root().
462 // is owned by the #JsonGenerator and it should not be freed
463 // RETURNS: a #JsonNode, or %NULL. The returned node
465 return json_generator_get_root(&this);
468 // Sets the number of repetitions for each indentation level.
469 // <indent_level>: the number of repetitions of the indentation character that should be applied when pretty printing
470 void set_indent(uint indent_level
) {
471 json_generator_set_indent(&this, indent_level
);
474 // Sets the character to be used when indenting
475 // <indent_char>: a Unicode character to be used when indenting
476 void set_indent_char(dchar indent_char
) {
477 json_generator_set_indent_char(&this, indent_char
);
480 // Sets whether the generated JSON should be pretty printed, using the
481 // indentation character specified in the #JsonGenerator:indent-char
482 // property and the spacing specified in #JsonGenerator:indent property.
483 // <is_pretty>: whether the generated string should be pretty printed
484 void set_pretty(int is_pretty
) {
485 json_generator_set_pretty(&this, is_pretty
);
488 // Sets @node as the root of the JSON data stream to be serialized by
489 // the #JsonGenerator.
491 // <note>The node is copied by the generator object, so it can be safely
492 // freed after calling this function.</note>
493 // <node>: a #JsonNode
494 void set_root(Node
* node
) {
495 json_generator_set_root(&this, node
);
498 // Generates a JSON data stream from @generator and returns it as a
501 // Use g_free() to free the allocated resources.
502 // RETURNS: a newly allocated buffer holding a JSON data stream.
503 // <length>: return location for the length of the returned buffer, or %NULL
504 char* /*new*/ to_data(/*out*/ size_t
* length
) {
505 return json_generator_to_data(&this, length
);
508 // Creates a JSON data stream and puts it inside @filename, overwriting the
509 // current file contents. This operation is atomic.
510 // RETURNS: %TRUE if saving was successful.
511 // <filename>: path to the target file
512 int to_file(char* filename
, GLib2
.Error
** error
=null) {
513 return json_generator_to_file(&this, filename
, error
);
516 // Outputs JSON data and streams it (synchronously) to @stream.
518 // on failure. In case of error, the #GError will be filled accordingly
519 // RETURNS: %TRUE if the write operation was successful, and %FALSE
520 // <stream>: a #GOutputStream
521 // <cancellable>: a #GCancellable, or %NULL
522 int to_stream(Gio2
.OutputStream
* stream
, Gio2
.Cancellable
* cancellable
, GLib2
.Error
** error
=null) {
523 return json_generator_to_stream(&this, stream
, cancellable
, error
);
527 // #JsonGenerator class
528 struct GeneratorClass
{
529 private GObject2
.ObjectClass parent_class
;
530 extern (C
) void function () _json_reserved1
;
531 extern (C
) void function () _json_reserved2
;
532 extern (C
) void function () _json_reserved3
;
533 extern (C
) void function () _json_reserved4
;
536 struct GeneratorPrivate
{
540 // A generic container of JSON data types. The contents of the #JsonNode
541 // structure are private and should only be accessed via the provided
542 // functions and never directly.
545 // Creates a new #JsonNode of @type.
546 // RETURNS: the newly created #JsonNode
547 // <type>: a #JsonNodeType
548 static Node
* /*new*/ new_(NodeType type
) {
549 return json_node_new(type
);
552 // Copies @node. If the node contains complex data types then the reference
553 // count of the objects is increased.
554 // RETURNS: the copied #JsonNode
555 Node
* /*new*/ copy() {
556 return json_node_copy(&this);
559 // Retrieves the #JsonArray stored inside a #JsonNode and returns it
560 // with its reference count increased by one.
563 // RETURNS: the #JsonArray with its reference
564 Array
* /*new*/ dup_array() {
565 return json_node_dup_array(&this);
568 // Retrieves the #JsonObject inside @node. The reference count of
569 // the returned object is increased.
570 // RETURNS: the #JsonObject
571 Object
* /*new*/ dup_object() {
572 return json_node_dup_object(&this);
575 // Gets a copy of the string value stored inside a #JsonNode
577 // of the #JsonNode contents. Use g_free() to free the allocated resources
578 // RETURNS: a newly allocated string containing a copy
579 char* /*new*/ dup_string() {
580 return json_node_dup_string(&this);
582 // Frees the resources allocated by @node.
584 json_node_free(&this);
587 // Retrieves the #JsonArray stored inside a #JsonNode
588 // RETURNS: the #JsonArray
590 return json_node_get_array(&this);
593 // Gets the boolean value stored inside a #JsonNode
594 // RETURNS: a boolean value.
596 return json_node_get_boolean(&this);
599 // Gets the double value stored inside a #JsonNode
600 // RETURNS: a double value.
601 double get_double() {
602 return json_node_get_double(&this);
605 // Gets the integer value stored inside a #JsonNode
606 // RETURNS: an integer value.
608 return json_node_get_int(&this);
611 // Retrieves the #JsonNodeType of @node
612 // RETURNS: the type of the node
613 NodeType
get_node_type() {
614 return json_node_get_node_type(&this);
617 // Retrieves the #JsonObject stored inside a #JsonNode
618 // RETURNS: the #JsonObject
619 Object
* get_object() {
620 return json_node_get_object(&this);
623 // Retrieves the parent #JsonNode of @node.
626 // RETURNS: the parent node, or %NULL if @node is
628 return json_node_get_parent(&this);
631 // Gets the string value stored inside a #JsonNode
632 // RETURNS: a string value.
634 return json_node_get_string(&this);
637 // Retrieves a value from a #JsonNode and copies into @value. When done
638 // using it, call g_value_unset() on the #GValue.
639 // <value>: return location for an uninitialized value
640 void get_value(/*out*/ GObject2
.Value
* value
) {
641 json_node_get_value(&this, value
);
644 // Returns the #GType of the payload of the node.
645 // RETURNS: a #GType for the payload.
646 Type
get_value_type() {
647 return json_node_get_value_type(&this);
650 // Checks whether @node is a %JSON_NODE_NULL
652 // <note>A null node is not the same as a %NULL #JsonNode</note>
653 // RETURNS: %TRUE if the node is null
655 return json_node_is_null(&this);
658 // Sets @array inside @node and increases the #JsonArray reference count
659 // <array>: a #JsonArray
660 void set_array(Array
* array
) {
661 json_node_set_array(&this, array
);
664 // Sets @value as the boolean content of the @node, replacing any existing
666 // <value>: a boolean value
667 void set_boolean(int value
) {
668 json_node_set_boolean(&this, value
);
671 // Sets @value as the double content of the @node, replacing any existing
673 // <value>: a double value
674 void set_double(double value
) {
675 json_node_set_double(&this, value
);
678 // Sets @value as the integer content of the @node, replacing any existing
680 // <value>: an integer value
681 void set_int(long value
) {
682 json_node_set_int(&this, value
);
685 // Sets @objects inside @node. The reference count of @object is increased.
686 // <object>: a #JsonObject
687 void set_object(Object
* object
) {
688 json_node_set_object(&this, object
);
691 // Sets the parent #JsonNode of @node
692 // <parent>: the parent #JsonNode of @node
693 void set_parent(Node
* parent
) {
694 json_node_set_parent(&this, parent
);
697 // Sets @value as the string content of the @node, replacing any existing
699 // <value>: a string value
700 void set_string(char* value
) {
701 json_node_set_string(&this, value
);
704 // Sets @value inside @node. The passed #GValue is copied into the #JsonNode
705 // <value>: the #GValue to set
706 void set_value(GObject2
.Value
* value
) {
707 json_node_set_value(&this, value
);
710 // Sets @array into @node without increasing the #JsonArray reference count.
711 // <array>: a #JsonArray
712 void take_array(Array
* array
) {
713 json_node_take_array(&this, array
);
716 // Sets @object inside @node. The reference count of @object is not increased.
717 // <object>: a #JsonObject
718 void take_object(Object
* object
) {
719 json_node_take_object(&this, object
);
722 // Retrieves the user readable name of the data type contained by @node.
724 // is owned by the node and should never be modified or freed
725 // RETURNS: a string containing the name of the type. The returned string
727 return json_node_type_name(&this);
731 // Indicates the content of a #JsonNode.
739 // A JSON object type. The contents of the #JsonObject structure are private
740 // and should only be accessed by the provided API
743 // Creates a new #JsonObject, an JSON object type representation.
744 // RETURNS: the newly created #JsonObject
745 static Object
* /*new*/ new_() {
746 return json_object_new();
749 // Adds a member named @member_name and containing @node into a #JsonObject.
750 // The object will take ownership of the #JsonNode.
752 // This function will return if the @object already contains a member
754 // <member_name>: the name of the member
755 // <node>: the value of the member
756 void add_member(char* member_name
, Node
* node
) {
757 json_object_add_member(&this, member_name
, node
);
760 // Retrieves a copy of the #JsonNode containing the value of @member_name
761 // inside a #JsonObject
763 // object member or %NULL. Use json_node_free() when done.
764 // RETURNS: a copy of the node for the requested
765 // <member_name>: the name of the JSON object member to access
766 Node
* /*new*/ dup_member(char* member_name
) {
767 return json_object_dup_member(&this, member_name
);
770 // Iterates over all members of @object and calls @func on
773 // It is safe to change the value of a #JsonNode of the @object
774 // from within the iterator @func, but it is not safe to add or
775 // remove members from the @object.
776 // <func>: the function to be called on each member
777 // <data>: data to be passed to the function
778 void foreach_member(ObjectForeach func
, void* data
) {
779 json_object_foreach_member(&this, func
, data
);
782 // Convenience function that retrieves the array
783 // stored in @member_name of @object
785 // See also: json_object_get_member()
786 // RETURNS: the array inside the object's member
787 // <member_name>: the name of the member
788 Array
* get_array_member(char* member_name
) {
789 return json_object_get_array_member(&this, member_name
);
792 // Convenience function that retrieves the boolean value
793 // stored in @member_name of @object
795 // See also: json_object_get_member()
796 // RETURNS: the boolean value of the object's member
797 // <member_name>: the name of the member
798 int get_boolean_member(char* member_name
) {
799 return json_object_get_boolean_member(&this, member_name
);
802 // Convenience function that retrieves the floating point value
803 // stored in @member_name of @object
805 // See also: json_object_get_member()
806 // RETURNS: the floating point value of the object's member
807 // <member_name>: the name of the member
808 double get_double_member(char* member_name
) {
809 return json_object_get_double_member(&this, member_name
);
812 // Convenience function that retrieves the integer value
813 // stored in @member_name of @object
815 // See also: json_object_get_member()
816 // RETURNS: the integer value of the object's member
817 // <member_name>: the name of the member
818 long get_int_member(char* member_name
) {
819 return json_object_get_int_member(&this, member_name
);
822 // Retrieves the #JsonNode containing the value of @member_name inside
826 // RETURNS: a pointer to the node for the requested object
827 // <member_name>: the name of the JSON object member to access
828 Node
* get_member(char* member_name
) {
829 return json_object_get_member(&this, member_name
);
832 // Retrieves all the names of the members of a #JsonObject. You can
833 // obtain the value for each member using json_object_get_member().
835 // of member names. The content of the list is owned by the #JsonObject
836 // and should never be modified or freed. When you have finished using
837 // the returned list, use g_list_free() to free the resources it has
840 GLib2
.List
* /*new container*/ get_members() {
841 return json_object_get_members(&this);
844 // Convenience function that checks whether the value
845 // stored in @member_name of @object is null
847 // See also: json_object_get_member()
848 // RETURNS: %TRUE if the value is null
849 // <member_name>: the name of the member
850 int get_null_member(char* member_name
) {
851 return json_object_get_null_member(&this, member_name
);
854 // Convenience function that retrieves the object
855 // stored in @member_name of @object
857 // See also: json_object_get_member()
858 // RETURNS: the object inside the object's member
859 // <member_name>: the name of the member
860 Object
* get_object_member(char* member_name
) {
861 return json_object_get_object_member(&this, member_name
);
864 // Retrieves the number of members of a #JsonObject.
865 // RETURNS: the number of members
867 return json_object_get_size(&this);
870 // Convenience function that retrieves the string value
871 // stored in @member_name of @object
873 // See also: json_object_get_member()
874 // RETURNS: the string value of the object's member
875 // <member_name>: the name of the member
876 char* get_string_member(char* member_name
) {
877 return json_object_get_string_member(&this, member_name
);
880 // Retrieves all the values of the members of a #JsonObject.
882 // #JsonNode<!-- -->s. The content of the list is owned by the #JsonObject
883 // and should never be modified or freed. When you have finished using the
884 // returned list, use g_list_free() to free the resources it has allocated.
885 // RETURNS: a #GList of
886 GLib2
.List
* /*new container*/ get_values() {
887 return json_object_get_values(&this);
890 // Checks whether @object has a member named @member_name.
891 // RETURNS: %TRUE if the JSON object has the requested member
892 // <member_name>: the name of a JSON object member
893 int has_member(char* member_name
) {
894 return json_object_has_member(&this, member_name
);
897 // Increase by one the reference count of a #JsonObject.
900 // RETURNS: the passed #JsonObject, with the reference count
901 Object
* /*new*/ ref_() {
902 return json_object_ref(&this);
905 // Removes @member_name from @object, freeing its allocated resources.
906 // <member_name>: the name of the member to remove
907 void remove_member(char* member_name
) {
908 json_object_remove_member(&this, member_name
);
911 // Convenience function for setting an array @value of
912 // @member_name inside @object.
914 // The @object will take ownership of the passed #JsonArray
916 // See also: json_object_set_member()
917 // <member_name>: the name of the member
918 // <value>: the value of the member
919 void set_array_member(char* member_name
, Array
* value
) {
920 json_object_set_array_member(&this, member_name
, value
);
923 // Convenience function for setting a boolean @value of
924 // @member_name inside @object.
926 // See also: json_object_set_member()
927 // <member_name>: the name of the member
928 // <value>: the value of the member
929 void set_boolean_member(char* member_name
, int value
) {
930 json_object_set_boolean_member(&this, member_name
, value
);
933 // Convenience function for setting a floating point @value
934 // of @member_name inside @object.
936 // See also: json_object_set_member()
937 // <member_name>: the name of the member
938 // <value>: the value of the member
939 void set_double_member(char* member_name
, double value
) {
940 json_object_set_double_member(&this, member_name
, value
);
943 // Convenience function for setting an integer @value of
944 // @member_name inside @object.
946 // See also: json_object_set_member()
947 // <member_name>: the name of the member
948 // <value>: the value of the member
949 void set_int_member(char* member_name
, long value
) {
950 json_object_set_int_member(&this, member_name
, value
);
953 // Sets @node as the value of @member_name inside @object.
955 // If @object already contains a member called @member_name then
956 // the member's current value is overwritten. Otherwise, a new
957 // member is added to @object.
958 // <member_name>: the name of the member
959 // <node>: the value of the member
960 void set_member(char* member_name
, Node
* node
) {
961 json_object_set_member(&this, member_name
, node
);
964 // Convenience function for setting a null @value of
965 // @member_name inside @object.
967 // See also: json_object_set_member()
968 // <member_name>: the name of the member
969 void set_null_member(char* member_name
) {
970 json_object_set_null_member(&this, member_name
);
973 // Convenience function for setting an object @value of
974 // @member_name inside @object.
976 // The @object will take ownership of the passed #JsonObject
978 // See also: json_object_set_member()
979 // <member_name>: the name of the member
980 // <value>: the value of the member
981 void set_object_member(char* member_name
, Object
* value
) {
982 json_object_set_object_member(&this, member_name
, value
);
985 // Convenience function for setting a string @value of
986 // @member_name inside @object.
988 // See also: json_object_set_member()
989 // <member_name>: the name of the member
990 // <value>: the value of the member
991 void set_string_member(char* member_name
, char* value
) {
992 json_object_set_string_member(&this, member_name
, value
);
995 // Decreases by one the reference count of a #JsonObject. If the
996 // reference count reaches zero, the object is destroyed and all
997 // its allocated resources are freed.
999 json_object_unref(&this);
1004 // The function to be passed to json_object_foreach_member(). You
1005 // should not add or remove members to and from @object within
1006 // this function. It is safe to change the value of @member_node.
1007 // <object>: the iterated #JsonObject
1008 // <member_name>: the name of the member
1009 // <member_node>: a #JsonNode containing the @member_name value
1010 // <user_data>: data passed to the function
1011 extern (C
) alias void function (Object
* object
, char* member_name
, Node
* member_node
, void* user_data
) ObjectForeach
;
1014 // JSON data streams parser. The contents of the #JsonParser structure are
1015 // private and should only be accessed via the provided API.
1016 struct Parser
/* : GObject.Object */ {
1017 alias parent_instance
this;
1018 alias parent_instance super_
;
1019 alias parent_instance object
;
1020 GObject2
.Object parent_instance
;
1021 private ParserPrivate
* priv
;
1024 // Creates a new #JsonParser instance. You can use the #JsonParser to
1025 // load a JSON stream from either a file or a buffer and then walk the
1026 // hierarchy using the data types API.
1028 // to release all the memory it allocates.
1029 // RETURNS: the newly created #JsonParser. Use g_object_unref()
1030 static Parser
* /*new*/ new_() {
1031 return json_parser_new();
1033 static GLib2
.Quark
error_quark() {
1034 return json_parser_error_quark();
1037 // Retrieves the line currently parsed, starting from 1.
1039 // This function has defined behaviour only while parsing; calling this
1040 // function from outside the signal handlers emitted by #JsonParser will
1042 // RETURNS: the currently parsed line, or 0.
1043 uint get_current_line() {
1044 return json_parser_get_current_line(&this);
1047 // Retrieves the current position inside the current line, starting
1050 // This function has defined behaviour only while parsing; calling this
1051 // function from outside the signal handlers emitted by #JsonParser will
1053 // RETURNS: the position in the current line, or 0.
1054 uint get_current_pos() {
1055 return json_parser_get_current_pos(&this);
1058 // Retrieves the top level node from the parsed JSON stream.
1060 // node is owned by the #JsonParser and should never be modified
1062 // RETURNS: the root #JsonNode . The returned
1064 return json_parser_get_root(&this);
1067 // A JSON data stream might sometimes contain an assignment, like:
1070 // var _json_data = { "member_name" : [ ...
1073 // even though it would technically constitute a violation of the RFC.
1075 // #JsonParser will ignore the left hand identifier and parse the right
1076 // hand value of the assignment. #JsonParser will record, though, the
1077 // existence of the assignment in the data stream and the variable name
1080 // @variable_name is not %NULL it will be set to the name of the variable
1081 // used in the assignment. The string is owned by #JsonParser and should
1082 // never be modified or freed.
1083 // RETURNS: %TRUE if there was an assignment, %FALSE otherwise. If
1084 // <variable_name>: Return location for the variable name, or %NULL
1085 int has_assignment(/*out*/ char** variable_name
=null) {
1086 return json_parser_has_assignment(&this, variable_name
);
1089 // Loads a JSON stream from a buffer and parses it. You can call this function
1090 // multiple times with the same #JsonParser object, but the contents of the
1091 // parser will be destroyed each time.
1093 // of error, @error is set accordingly and %FALSE is returned
1094 // RETURNS: %TRUE if the buffer was succesfully parser. In case
1095 // <data>: the buffer to parse
1096 // <length>: the length of the buffer, or -1
1097 int load_from_data(char* data
, ssize_t length
, GLib2
.Error
** error
=null) {
1098 return json_parser_load_from_data(&this, data
, length
, error
);
1101 // Loads a JSON stream from the content of @filename and parses it. See
1102 // json_parser_load_from_data().
1104 // In case of error, @error is set accordingly and %FALSE is returned
1105 // RETURNS: %TRUE if the file was successfully loaded and parsed.
1106 // <filename>: the path for the file to parse
1107 int load_from_file(char* filename
, GLib2
.Error
** error
=null) {
1108 return json_parser_load_from_file(&this, filename
, error
);
1111 // Loads the contents of an input stream and parses them.
1113 // If @cancellable is not %NULL, then the operation can be cancelled by
1114 // triggering the @cancellable object from another thread. If the
1115 // operation was cancelled, the error %G_IO_ERROR_CANCELLED will be set
1116 // on the passed @error.
1118 // parsed, and %FALSE otherwise
1119 // RETURNS: %TRUE if the data stream was successfully read and
1120 // <stream>: an open #GInputStream
1121 // <cancellable>: a #GCancellable, or %NULL
1122 int load_from_stream(Gio2
.InputStream
* stream
, Gio2
.Cancellable
* cancellable
, GLib2
.Error
** error
=null) {
1123 return json_parser_load_from_stream(&this, stream
, cancellable
, error
);
1126 // Asynchronously reads the contents of @stream.
1128 // For more details, see json_parser_load_from_stream() which is the
1129 // synchronous version of this call.
1131 // When the operation is finished, @callback will be called. You should
1132 // then call json_parser_load_from_stream_finish() to get the result
1133 // of the operation.
1134 // <stream>: a #GInputStream
1135 // <cancellable>: a #GCancellable, or %NULL
1136 // <callback>: a #GAsyncReadyCallback to call when the request is satisfied
1137 // <user_data>: the data to pass to @callback
1138 void load_from_stream_async(Gio2
.InputStream
* stream
, Gio2
.Cancellable
* cancellable
, Gio2
.AsyncReadyCallback callback
, void* user_data
) {
1139 json_parser_load_from_stream_async(&this, stream
, cancellable
, callback
, user_data
);
1142 // Finishes an asynchronous stream loading started with
1143 // json_parser_load_from_stream_async().
1145 // and parsed, and %FALSE otherwise. In case of error, the #GError will be
1146 // filled accordingly.
1147 // RETURNS: %TRUE if the content of the stream was successfully retrieves
1148 // <result>: a #GAsyncResult
1149 int load_from_stream_finish(Gio2
.AsyncResult
* result
, GLib2
.Error
** error
=null) {
1150 return json_parser_load_from_stream_finish(&this, result
, error
);
1153 // The ::array-element signal is emitted each time the #JsonParser
1154 // has successfully parsed a single element of a #JsonArray. The
1155 // array and element index are passed to the signal handlers.
1156 // <array>: a #JsonArray
1157 // <index_>: the index of the newly parsed element
1158 extern (C
) alias static void function (Parser
* this_
, Array
* array
, int index_
, void* user_data
=null) signal_array_element
;
1160 ulong signal_connect(string name
, CB
)(CB cb
, void* data
=null, ConnectFlags cf
=cast(ConnectFlags
)0) {
1161 return super_
.signal_connect
!name(cb
, data
, cf
);
1164 ulong signal_connect(string name
:"array-element", CB
/*:signal_array_element*/)(CB cb
, void* data
=null, ConnectFlags cf
=cast(ConnectFlags
)0) {
1165 return signal_connect_data(&this, cast(char*)"array-element",
1166 cast(GObject2
.Callback
)cb
, data
, null, cf
);
1169 // The ::array-end signal is emitted each time the #JsonParser
1170 // has successfully parsed an entire #JsonArray
1171 // <array>: the parsed #JsonArray
1172 extern (C
) alias static void function (Parser
* this_
, Array
* array
, void* user_data
=null) signal_array_end
;
1173 ulong signal_connect(string name
:"array-end", CB
/*:signal_array_end*/)(CB cb
, void* data
=null, ConnectFlags cf
=cast(ConnectFlags
)0) {
1174 return signal_connect_data(&this, cast(char*)"array-end",
1175 cast(GObject2
.Callback
)cb
, data
, null, cf
);
1178 // The ::array-start signal is emitted each time the #JsonParser
1179 // starts parsing a #JsonArray
1180 extern (C
) alias static void function (Parser
* this_
, void* user_data
=null) signal_array_start
;
1181 ulong signal_connect(string name
:"array-start", CB
/*:signal_array_start*/)(CB cb
, void* data
=null, ConnectFlags cf
=cast(ConnectFlags
)0) {
1182 return signal_connect_data(&this, cast(char*)"array-start",
1183 cast(GObject2
.Callback
)cb
, data
, null, cf
);
1186 // The ::error signal is emitted each time a #JsonParser encounters
1187 // an error in a JSON stream.
1188 // <error>: a pointer to the #GError
1189 extern (C
) alias static void function (Parser
* this_
, void* error
, void* user_data
=null) signal_error
;
1190 ulong signal_connect(string name
:"error", CB
/*:signal_error*/)(CB cb
, void* data
=null, ConnectFlags cf
=cast(ConnectFlags
)0) {
1191 return signal_connect_data(&this, cast(char*)"error",
1192 cast(GObject2
.Callback
)cb
, data
, null, cf
);
1195 // The ::object-end signal is emitted each time the #JsonParser
1196 // has successfully parsed an entire #JsonObject.
1197 // <object>: the parsed #JsonObject
1198 extern (C
) alias static void function (Parser
* this_
, Object
* object
, void* user_data
=null) signal_object_end
;
1199 ulong signal_connect(string name
:"object-end", CB
/*:signal_object_end*/)(CB cb
, void* data
=null, ConnectFlags cf
=cast(ConnectFlags
)0) {
1200 return signal_connect_data(&this, cast(char*)"object-end",
1201 cast(GObject2
.Callback
)cb
, data
, null, cf
);
1204 // The ::object-member signal is emitted each time the #JsonParser
1205 // has successfully parsed a single member of a #JsonObject. The
1206 // object and member are passed to the signal handlers.
1207 // <object>: a #JsonObject
1208 // <member_name>: the name of the newly parsed member
1209 extern (C
) alias static void function (Parser
* this_
, Object
* object
, char* member_name
, void* user_data
=null) signal_object_member
;
1210 ulong signal_connect(string name
:"object-member", CB
/*:signal_object_member*/)(CB cb
, void* data
=null, ConnectFlags cf
=cast(ConnectFlags
)0) {
1211 return signal_connect_data(&this, cast(char*)"object-member",
1212 cast(GObject2
.Callback
)cb
, data
, null, cf
);
1215 // The ::object-start signal is emitted each time the #JsonParser
1216 // starts parsing a #JsonObject.
1217 extern (C
) alias static void function (Parser
* this_
, void* user_data
=null) signal_object_start
;
1218 ulong signal_connect(string name
:"object-start", CB
/*:signal_object_start*/)(CB cb
, void* data
=null, ConnectFlags cf
=cast(ConnectFlags
)0) {
1219 return signal_connect_data(&this, cast(char*)"object-start",
1220 cast(GObject2
.Callback
)cb
, data
, null, cf
);
1223 // The ::parse-end signal is emitted when the parser successfully
1224 // finished parsing a JSON data stream
1225 extern (C
) alias static void function (Parser
* this_
, void* user_data
=null) signal_parse_end
;
1226 ulong signal_connect(string name
:"parse-end", CB
/*:signal_parse_end*/)(CB cb
, void* data
=null, ConnectFlags cf
=cast(ConnectFlags
)0) {
1227 return signal_connect_data(&this, cast(char*)"parse-end",
1228 cast(GObject2
.Callback
)cb
, data
, null, cf
);
1231 // The ::parse-start signal is emitted when the parser began parsing
1232 // a JSON data stream.
1233 extern (C
) alias static void function (Parser
* this_
, void* user_data
=null) signal_parse_start
;
1234 ulong signal_connect(string name
:"parse-start", CB
/*:signal_parse_start*/)(CB cb
, void* data
=null, ConnectFlags cf
=cast(ConnectFlags
)0) {
1235 return signal_connect_data(&this, cast(char*)"parse-start",
1236 cast(GObject2
.Callback
)cb
, data
, null, cf
);
1240 // #JsonParser class.
1241 struct ParserClass
{
1242 private GObject2
.ObjectClass parent_class
;
1243 extern (C
) void function (Parser
* parser
) parse_start
;
1244 extern (C
) void function (Parser
* parser
) object_start
;
1245 extern (C
) void function (Parser
* parser
, Object
* object
, char* member_name
) object_member
;
1246 extern (C
) void function (Parser
* parser
, Object
* object
) object_end
;
1247 extern (C
) void function (Parser
* parser
) array_start
;
1248 extern (C
) void function (Parser
* parser
, Array
* array
, int index_
) array_element
;
1249 extern (C
) void function (Parser
* parser
, Array
* array
) array_end
;
1250 extern (C
) void function (Parser
* parser
) parse_end
;
1251 extern (C
) void function (Parser
* parser
, GLib2
.Error
* error
) error
;
1252 extern (C
) void function () _json_reserved1
;
1253 extern (C
) void function () _json_reserved2
;
1254 extern (C
) void function () _json_reserved3
;
1255 extern (C
) void function () _json_reserved4
;
1256 extern (C
) void function () _json_reserved5
;
1257 extern (C
) void function () _json_reserved6
;
1258 extern (C
) void function () _json_reserved7
;
1259 extern (C
) void function () _json_reserved8
;
1263 // Error enumeration for #JsonParser
1265 // This enumeration can be extended at later date
1271 INVALID_BAREWORD
= 4,
1274 struct ParserPrivate
{
1278 // The <structname>JsonPath</structname> structure is an opaque object
1279 // whose members cannot be directly accessed except through the provided
1281 struct Path
/* : GObject.Object */ /* Version 0.14 */ {
1282 alias method_parent
this;
1283 alias method_parent super_
;
1284 alias method_parent object
;
1285 GObject2
.Object method_parent
;
1288 // Creates a new #JsonPath instance.
1290 // Once created, the #JsonPath object should be used with json_path_compile()
1291 // and json_path_match().
1293 // g_object_unref() to free the allocated resources when done
1294 // RETURNS: the newly created #JsonPath instance. Use
1295 static Path
* /*new*/ new_() {
1296 return json_path_new();
1298 static GLib2
.Quark
error_quark() {
1299 return json_path_error_quark();
1302 // Queries a JSON tree using a JSONPath expression.
1304 // This function is a simple wrapper around json_path_new(),
1305 // json_path_compile() and json_path_match(). It implicitly
1306 // creates a #JsonPath instance, compiles @expression and
1307 // matches it against the JSON tree pointed by @root.
1309 // %JSON_NODE_ARRAY containing an array of matching #JsonNode<!-- -->s.
1310 // Use json_node_free() when done
1311 // RETURNS: a newly-created #JsonNode of type
1312 // <expression>: a JSONPath expression
1313 // <root>: the root of a JSON tree
1314 static Node
* /*new*/ query(char* expression
, Node
* root
, GLib2
.Error
** error
=null) {
1315 return json_path_query(expression
, root
, error
);
1318 // Validates and decomposes @expression.
1320 // A JSONPath expression must be compiled before calling json_path_match().
1322 // the %JSON_PATH_ERROR domain and a code from the #JsonPathError
1323 // enumeration, and %FALSE will be returned
1324 // RETURNS: %TRUE on success; on error, @error will be set with
1325 // <expression>: a JSONPath expression
1326 int compile(char* expression
, GLib2
.Error
** error
=null) {
1327 return json_path_compile(&this, expression
, error
);
1330 // Matches the JSON tree pointed by @root using the expression compiled
1331 // into the #JsonPath.
1333 // The matching #JsonNode<!-- -->s will be copied into a #JsonArray and
1334 // returned wrapped in a #JsonNode.
1336 // %JSON_NODE_ARRAY containing an array of matching #JsonNode<!-- -->s.
1337 // Use json_node_free() when done
1338 // RETURNS: a newly-created #JsonNode of type
1339 // <root>: a #JsonNode
1340 Node
* /*new*/ match(Node
* root
) {
1341 return json_path_match(&this, root
);
1346 // The <structname>JsonPathClass</structname> structure is an opaque
1347 // object class whose members cannot be directly accessed.
1348 struct PathClass
/* Version 0.14 */ {
1351 // Error code enumeration for the %JSON_PATH_ERROR domain.
1352 enum PathError
/* Version 0.14 */ {
1353 PATH_ERROR_INVALID_QUERY
= 0
1356 // The <structname>JsonReader</structname> structure contains only
1357 // private data and should only be accessed using the provided API
1358 struct Reader
/* : GObject.Object */ /* Version 0.12 */ {
1359 alias parent_instance
this;
1360 alias parent_instance super_
;
1361 alias parent_instance object
;
1362 GObject2
.Object parent_instance
;
1363 private ReaderPrivate
* priv
;
1366 // Creates a new #JsonReader. You can use this object to read the contents of
1367 // the JSON tree starting from @node
1369 // release the allocated resources when done
1370 // RETURNS: the newly created #JsonReader. Use g_object_unref() to
1371 // <node>: a #JsonNode, or %NULL
1372 static Reader
* /*new*/ new_(Node
* node
=null) {
1373 return json_reader_new(node
);
1375 static GLib2
.Quark
error_quark() {
1376 return json_reader_error_quark();
1379 // Counts the elements of the current position, if @reader is
1380 // positioned on an array
1382 // the #JsonReader is set in an error state
1383 // RETURNS: the number of elements, or -1. In case of failure
1384 int count_elements() {
1385 return json_reader_count_elements(&this);
1388 // Counts the members of the current position, if @reader is
1389 // positioned on an object
1391 // the #JsonReader is set in an error state
1392 // RETURNS: the number of members, or -1. In case of failure
1393 int count_members() {
1394 return json_reader_count_members(&this);
1397 // Moves the cursor back to the previous node after being positioned
1400 // This function resets the error state of @reader, if any was set
1401 void end_element() {
1402 json_reader_end_element(&this);
1405 // Moves the cursor back to the previous node after being positioned
1408 // This function resets the error state of @reader, if any was set
1410 json_reader_end_member(&this);
1413 // Retrieves the boolean value of the current position of @reader
1414 // RETURNS: the boolean value
1415 int get_boolean_value() {
1416 return json_reader_get_boolean_value(&this);
1419 // Retrieves the floating point value of the current position of @reader
1420 // RETURNS: the floating point value
1421 double get_double_value() {
1422 return json_reader_get_double_value(&this);
1425 // Retrieves the #GError currently set on @reader, if the #JsonReader
1426 // is in error state
1427 // RETURNS: the pointer to the error, or %NULL
1428 GLib2
.Error
* get_error() {
1429 return json_reader_get_error(&this);
1432 // Retrieves the integer value of the current position of @reader
1433 // RETURNS: the integer value
1434 long get_int_value() {
1435 return json_reader_get_int_value(&this);
1438 // Retrieves the name of the current member.
1439 // RETURNS: the name of the member, or %NULL
1440 char* get_member_name() {
1441 return json_reader_get_member_name(&this);
1444 // Checks whether the value of the current position of @reader is 'null'
1445 // RETURNS: %TRUE if 'null' is set, and %FALSE otherwise
1446 int get_null_value() {
1447 return json_reader_get_null_value(&this);
1450 // Retrieves the string value of the current position of @reader
1451 // RETURNS: the string value
1452 char* get_string_value() {
1453 return json_reader_get_string_value(&this);
1456 // Retrieves the #JsonNode of the current position of @reader
1458 // is owned by the #JsonReader and it should not be modified or freed
1460 // RETURNS: a #JsonNode, or %NULL. The returned node
1462 return json_reader_get_value(&this);
1465 // Checks whether the @reader is currently on an array
1468 // RETURNS: %TRUE if the #JsonReader is on an array, and %FALSE
1470 return json_reader_is_array(&this);
1473 // Checks whether the @reader is currently on an object
1476 // RETURNS: %TRUE if the #JsonReader is on an object, and %FALSE
1478 return json_reader_is_object(&this);
1481 // Checks whether the @reader is currently on a value
1484 // RETURNS: %TRUE if the #JsonReader is on a value, and %FALSE
1486 return json_reader_is_value(&this);
1489 // Retrieves a list of member names from the current position, if @reader
1490 // is positioned on an object.
1492 // array of strings holding the members name. Use g_strfreev() when
1494 // RETURNS: a newly allocated, %NULL-terminated
1495 char** /*new*/ list_members() {
1496 return json_reader_list_members(&this);
1499 // Advances the cursor of @reader to the element @index_ of the array
1500 // or the object at the current position.
1502 // You can use the json_reader_get_value* family of functions to retrieve
1503 // the value of the element; for instance:
1506 // json_reader_read_element (reader, 0);
1507 // int_value = json_reader_get_int_value (reader);
1510 // After reading the value, json_reader_end_element() should be called to
1511 // reposition the cursor inside the #JsonReader, e.g.:
1514 // json_reader_read_element (reader, 1);
1515 // str_value = json_reader_get_string_value (reader);
1516 // json_reader_end_element (reader);
1518 // json_reader_read_element (reader, 2);
1519 // str_value = json_reader_get_string_value (reader);
1520 // json_reader_end_element (reader);
1523 // If @reader is not currently on an array or an object, or if the @index_ is
1524 // bigger than the size of the array or the object, the #JsonReader will be
1525 // put in an error state until json_reader_end_element() is called.
1526 // RETURNS: %TRUE on success, and %FALSE otherwise
1527 // <index_>: the index of the element
1528 int read_element(uint index_
) {
1529 return json_reader_read_element(&this, index_
);
1532 // Advances the cursor of @reader to the @member_name of the object at the
1533 // current position.
1535 // You can use the json_reader_get_value* family of functions to retrieve
1536 // the value of the member; for instance:
1539 // json_reader_read_member (reader, "width");
1540 // width = json_reader_get_int_value (reader);
1543 // After reading the value, json_reader_end_member() should be called to
1544 // reposition the cursor inside the #JsonReader, e.g.:
1547 // json_reader_read_member (reader, "author");
1548 // author = json_reader_get_string_value (reader);
1549 // json_reader_end_element (reader);
1551 // json_reader_read_element (reader, "title");
1552 // title = json_reader_get_string_value (reader);
1553 // json_reader_end_element (reader);
1556 // If @reader is not currently on an object, or if the @member_name is not
1557 // defined in the object, the #JsonReader will be put in an error state until
1558 // json_reader_end_member() is called.
1559 // RETURNS: %TRUE on success, and %FALSE otherwise
1560 // <member_name>: the name of the member to read
1561 int read_member(char* member_name
) {
1562 return json_reader_read_member(&this, member_name
);
1565 // Sets the root #JsonNode to be read by @reader. The @reader will take
1568 // If another #JsonNode is currently set as root, it will be replaced.
1569 // <root>: a #JsonNode
1570 void set_root(Node
* root
=null) {
1571 json_reader_set_root(&this, root
);
1576 // The <structname>JsonReaderClass</structname> structure contains only
1578 struct ReaderClass
/* Version 0.12 */ {
1579 private GObject2
.ObjectClass parent_class
;
1580 extern (C
) void function () _json_padding0
;
1581 extern (C
) void function () _json_padding1
;
1582 extern (C
) void function () _json_padding2
;
1583 extern (C
) void function () _json_padding3
;
1584 extern (C
) void function () _json_padding4
;
1587 // Error codes enumeration for #JsonReader errors
1588 enum ReaderError
/* Version 0.12 */ {
1597 struct ReaderPrivate
{
1600 struct Serializable
{
1602 // Calls the default implementation of the #JsonSerializable
1603 // deserialize_property() virtual function
1605 // This function can be used inside a custom implementation
1606 // of the deserialize_property() virtual function in lieu of:
1609 // JsonSerializable *iface;
1612 // iface = g_type_default_interface_peek (JSON_TYPE_SERIALIZABLE);
1613 // res = iface->deserialize_property (serializable, property_name,
1618 // RETURNS: %TRUE if the property was successfully deserialized.
1619 // <property_name>: the name of the property
1620 // <value>: a pointer to an uninitialized #GValue
1621 // <pspec>: a #GParamSpec
1622 // <property_node>: a #JsonNode containing the serialized property
1623 int default_deserialize_property(char* property_name
, GObject2
.Value
* value
, GObject2
.ParamSpec
* pspec
, Node
* property_node
) {
1624 return json_serializable_default_deserialize_property(&this, property_name
, value
, pspec
, property_node
);
1627 // Calls the default implementation of the #JsonSerializable
1628 // serialize_property() virtual function
1630 // This function can be used inside a custom implementation
1631 // of the serialize_property() virtual function in lieu of:
1634 // JsonSerializable *iface;
1637 // iface = g_type_default_interface_peek (JSON_TYPE_SERIALIZABLE);
1638 // node = iface->serialize_property (serializable, property_name,
1644 // RETURNS: a #JsonNode containing the serialized
1645 // <property_name>: the name of the property
1646 // <value>: the value of the property
1647 // <pspec>: a #GParamSpec
1648 Node
* /*new*/ default_serialize_property(char* property_name
, GObject2
.Value
* value
, GObject2
.ParamSpec
* pspec
) {
1649 return json_serializable_default_serialize_property(&this, property_name
, value
, pspec
);
1652 // Asks a #JsonSerializable implementation to deserialize the
1653 // property contained inside @property_node into @value.
1654 // RETURNS: %TRUE if the property was successfully deserialized.
1655 // <property_name>: the name of the property
1656 // <value>: a pointer to an uninitialized #GValue
1657 // <pspec>: a #GParamSpec
1658 // <property_node>: a #JsonNode containing the serialized property
1659 int deserialize_property(char* property_name
, /*out*/ GObject2
.Value
* value
, GObject2
.ParamSpec
* pspec
, Node
* property_node
) {
1660 return json_serializable_deserialize_property(&this, property_name
, value
, pspec
, property_node
);
1665 // or %NULL if no property was found
1666 // RETURNS: the #GParamSpec for the property
1667 // <name>: the name of the property
1668 GObject2
.ParamSpec
* find_property(char* name
) {
1669 return json_serializable_find_property(&this, name
);
1671 void get_property(GObject2
.ParamSpec
* pspec
, GObject2
.Value
* value
) {
1672 json_serializable_get_property(&this, pspec
, value
);
1677 // of #GParamSpec. Use g_free() to free the array when done.
1678 // RETURNS: an array
1679 // <n_pspecs>: return location for the length of the array of #GParamSpec returned by the function
1680 GObject2
.ParamSpec
** /*new container*/ list_properties(/*out*/ uint* n_pspecs
) {
1681 return json_serializable_list_properties(&this, n_pspecs
);
1684 // Asks a #JsonSerializable implementation to serialize a #GObject
1685 // property into a #JsonNode object.
1686 // RETURNS: a #JsonNode containing the serialized property
1687 // <property_name>: the name of the property
1688 // <value>: the value of the property
1689 // <pspec>: a #GParamSpec
1690 Node
* /*new*/ serialize_property(char* property_name
, GObject2
.Value
* value
, GObject2
.ParamSpec
* pspec
) {
1691 return json_serializable_serialize_property(&this, property_name
, value
, pspec
);
1693 void set_property(GObject2
.ParamSpec
* pspec
, GObject2
.Value
* value
) {
1694 json_serializable_set_property(&this, pspec
, value
);
1699 // Interface that allows serializing and deserializing #GObject<!-- -->s
1700 // with properties storing complex data types. The json_serialize_gobject()
1701 // function will check if the passed #GObject implements this interface,
1702 // so it can also be used to override the default property serialization
1704 struct SerializableIface
{
1705 private GObject2
.TypeInterface g_iface
;
1707 // RETURNS: a #JsonNode containing the serialized property
1708 // <property_name>: the name of the property
1709 // <value>: the value of the property
1710 // <pspec>: a #GParamSpec
1711 extern (C
) Node
* /*new*/ function (Serializable
* serializable
, char* property_name
, GObject2
.Value
* value
, GObject2
.ParamSpec
* pspec
) serialize_property
;
1713 // RETURNS: %TRUE if the property was successfully deserialized.
1714 // <property_name>: the name of the property
1715 // <value>: a pointer to an uninitialized #GValue
1716 // <pspec>: a #GParamSpec
1717 // <property_node>: a #JsonNode containing the serialized property
1718 extern (C
) int function (Serializable
* serializable
, char* property_name
, /*out*/ GObject2
.Value
* value
, GObject2
.ParamSpec
* pspec
, Node
* property_node
) deserialize_property
;
1720 // RETURNS: the #GParamSpec for the property
1721 // <name>: the name of the property
1722 extern (C
) GObject2
.ParamSpec
* function (Serializable
* serializable
, char* name
) find_property
;
1723 // Unintrospectable functionp: list_properties() / ()
1724 extern (C
) GObject2
.ParamSpec
** function (Serializable
* serializable
, uint* n_pspecs
) list_properties
;
1725 extern (C
) void function (Serializable
* serializable
, GObject2
.ParamSpec
* pspec
, GObject2
.Value
* value
) set_property
;
1726 extern (C
) void function (Serializable
* serializable
, GObject2
.ParamSpec
* pspec
, GObject2
.Value
* value
) get_property
;
1730 // Checks whether it is possible to deserialize a #GBoxed of
1731 // type @gboxed_type from a #JsonNode of type @node_type
1732 // RETURNS: %TRUE if the type can be deserialized, %FALSE otherwise
1733 // <gboxed_type>: a boxed type
1734 // <node_type>: a #JsonNode type
1735 static int boxed_can_deserialize(Type gboxed_type
, NodeType node_type
) {
1736 return json_boxed_can_deserialize(gboxed_type
, node_type
);
1740 // Checks whether it is possible to serialize a #GBoxed of
1741 // type @gboxed_type into a #JsonNode. The type of the
1742 // #JsonNode is placed inside @node_type if the function
1743 // returns %TRUE and it's undefined otherwise.
1745 // and %FALSE otherwise.
1746 // RETURNS: %TRUE if the type can be serialized,
1747 // <gboxed_type>: a boxed type
1748 // <node_type>: the #JsonNode type to which the boxed type can be serialized into
1749 static int boxed_can_serialize(Type gboxed_type
, /*out*/ NodeType
* node_type
) {
1750 return json_boxed_can_serialize(gboxed_type
, node_type
);
1754 // Deserializes @node into a #GBoxed of @gboxed_type
1756 // g_boxed_free() to release the resources allocated by this
1758 // RETURNS: the newly allocated #GBoxed. Use
1759 // <gboxed_type>: a boxed type
1760 // <node>: a #JsonNode
1761 static void* /*new*/ boxed_deserialize(Type gboxed_type
, Node
* node
) {
1762 return json_boxed_deserialize(gboxed_type
, node
);
1766 // Unintrospectable function: boxed_register_deserialize_func() / json_boxed_register_deserialize_func()
1767 // Registers a deserialization function for a #GBoxed of type @gboxed_type
1768 // from a #JsonNode of type @node_type
1769 // <gboxed_type>: a boxed type
1770 // <node_type>: a node type
1771 // <deserialize_func>: deserialization function for @boxed_type from a #JsonNode of type @node_type
1772 static void boxed_register_deserialize_func(Type gboxed_type
, NodeType node_type
, BoxedDeserializeFunc deserialize_func
) {
1773 json_boxed_register_deserialize_func(gboxed_type
, node_type
, deserialize_func
);
1777 // Unintrospectable function: boxed_register_serialize_func() / json_boxed_register_serialize_func()
1778 // Registers a serialization function for a #GBoxed of type @gboxed_type
1779 // to a #JsonNode of type @node_type
1780 // <gboxed_type>: a boxed type
1781 // <node_type>: a node type
1782 // <serialize_func>: serialization function for @boxed_type into a #JsonNode of type @node_type
1783 static void boxed_register_serialize_func(Type gboxed_type
, NodeType node_type
, BoxedSerializeFunc serialize_func
) {
1784 json_boxed_register_serialize_func(gboxed_type
, node_type
, serialize_func
);
1788 // Serializes @boxed, a pointer to a #GBoxed of type @gboxed_type,
1791 // boxed type, or %NULL if serialization either failed or was not possible
1792 // RETURNS: a #JsonNode with the serialization of the
1793 // <gboxed_type>: a boxed type
1794 // <boxed>: a pointer to a #GBoxed of type @gboxed_type
1795 static Node
* /*new*/ boxed_serialize(Type gboxed_type
, const(void)* boxed
) {
1796 return json_boxed_serialize(gboxed_type
, boxed
);
1800 // Deserializes a JSON data stream and creates the corresponding
1801 // #GObject class. If @gtype implements the #JsonSerializableIface
1802 // interface, it will be asked to deserialize all the JSON members
1803 // into the respective properties; otherwise, the default implementation
1804 // will be used to translate the compatible JSON native types.
1806 // Note: the JSON data stream must be an object declaration.
1807 // RETURNS: a #GObject or %NULL
1808 // <gtype>: the #GType of object to construct
1809 // <data>: a JSON data stream
1810 // <length>: length of the data stream
1811 static GObject2
.Object
* /*new*/ construct_gobject(Type gtype
, char* data
, size_t length
, GLib2
.Error
** error
=null) {
1812 return json_construct_gobject(gtype
, data
, length
, error
);
1816 // Creates a new #GObject of type @gtype, and constructs it
1817 // using the members of the passed #JsonObject
1819 // instance. Use g_object_unref() to free the resources
1820 // allocated by this function
1821 // RETURNS: The newly created #GObject
1822 // <gtype>: the type of the #GObject to create
1823 // <node>: a #JsonNode of type %JSON_NODE_OBJECT describing the instance of type @gtype
1824 static GObject2
.Object
* /*new*/ gobject_deserialize(Type gtype
, Node
* node
) {
1825 return json_gobject_deserialize(gtype
, node
);
1829 // Deserializes a JSON data stream and creates the corresponding
1830 // #GObject class. If @gtype implements the #JsonSerializableIface
1831 // interface, it will be asked to deserialize all the JSON members
1832 // into the respective properties; otherwise, the default implementation
1833 // will be used to translate the compatible JSON native types.
1835 // Note: the JSON data stream must be an object declaration.
1836 // RETURNS: a #GObject or %NULL
1837 // <gtype>: the #GType of object to construct
1838 // <data>: a JSON data stream
1839 // <length>: length of the data stream, or -1 if it is NUL-terminated
1840 static GObject2
.Object
* /*new*/ gobject_from_data(Type gtype
, char* data
, ssize_t length
, GLib2
.Error
** error
=null) {
1841 return json_gobject_from_data(gtype
, data
, length
, error
);
1845 // Creates a #JsonNode representing the passed #GObject
1846 // instance. Each member of the returned JSON object will
1847 // map to a property of the #GObject
1849 // of type %JSON_NODE_OBJECT. Use json_node_free() to free
1850 // the resources allocated by this function
1851 // RETURNS: the newly created #JsonNode
1852 // <gobject>: a #GObject
1853 static Node
* /*new*/ gobject_serialize(GObject2
.Object
* gobject
) {
1854 return json_gobject_serialize(gobject
);
1858 // Serializes a #GObject into a JSON data stream, iterating recursively
1859 // over each property.
1861 // If @gobject implements the #JsonSerializableIface interface, it will
1862 // be asked to serialize all its properties; otherwise, the default
1863 // implementation will be use to translate the compatible types into
1864 // JSON native types.
1865 // RETURNS: a JSON data stream representing the passed #GObject
1866 // <gobject>: a #GObject
1867 // <length>: return value for the length of the buffer, or %NULL
1868 static char* /*new*/ gobject_to_data(GObject2
.Object
* gobject
, /*out*/ size_t
* length
) {
1869 return json_gobject_to_data(gobject
, length
);
1873 // Converts a JSON data structure to a GVariant value using @signature to
1874 // resolve ambiguous data types. If no error occurs, the resulting #GVariant
1875 // is guaranteed to conform to @signature.
1877 // If @signature is not %NULL but does not represent a valid GVariant type
1878 // string, %NULL is returned and error is set to %G_IO_ERROR_INVALID_ARGUMENT.
1879 // If a @signature is provided but the JSON structure cannot be mapped to it,
1880 // %NULL is returned and error is set to %G_IO_ERROR_INVALID_DATA.
1881 // If @signature is %NULL, the conversion is done based strictly on the types
1882 // in the JSON nodes.
1884 // @signature, or %NULL on error
1885 // RETURNS: A newly created #GVariant compliant with
1886 // <json_node>: A #JsonNode to convert
1887 // <signature>: A valid #GVariant type string, or %NULL
1888 static GLib2
.Variant
* /*new*/ gvariant_deserialize(Node
* json_node
, char* signature
, GLib2
.Error
** error
=null) {
1889 return json_gvariant_deserialize(json_node
, signature
, error
);
1893 // Converts a JSON string to a #GVariant value. This method works exactly
1894 // like json_gvariant_deserialize(), but takes a JSON encoded string instead.
1895 // The string is first converted to a #JsonNode using #JsonParser, and then
1896 // json_gvariant_deserialize() is called.
1898 // @signature, or %NULL on error
1899 // RETURNS: A newly created #GVariant compliant with
1900 // <json>: A JSON data string
1901 // <length>: The length of @json, or -1 if %NULL-terminated
1902 // <signature>: A valid #GVariant type string, or %NULL
1903 static GLib2
.Variant
* /*new*/ gvariant_deserialize_data(char* json
, ssize_t length
, char* signature
, GLib2
.Error
** error
=null) {
1904 return json_gvariant_deserialize_data(json
, length
, signature
, error
);
1908 // Converts @variant to a JSON tree.
1910 // JSON data structure obtained from @variant
1911 // RETURNS: A #JsonNode representing the root of the
1912 // <variant>: A #GVariant to convert
1913 static Node
* /*new*/ gvariant_serialize(GLib2
.Variant
* variant
) {
1914 return json_gvariant_serialize(variant
);
1918 // Converts @variant to its JSON encoded string representation. This method
1919 // is actually a helper function. It uses json_gvariant_serialize() to obtain the
1920 // JSON tree, and then #JsonGenerator to stringify it.
1923 // RETURNS: The JSON encoded string corresponding to
1924 // <variant>: A #GVariant to convert
1925 // <length>: Return location for the length of the returned string, or %NULL
1926 static char* /*new*/ gvariant_serialize_data(GLib2
.Variant
* variant
, /*out*/ size_t
* length
=null) {
1927 return json_gvariant_serialize_data(variant
, length
);
1931 // Serializes a #GObject into a JSON data stream. If @gobject implements
1932 // the #JsonSerializableIface interface, it will be asked to serizalize all
1933 // its properties; otherwise, the default implementation will be use to
1934 // translate the compatible types into JSON native types.
1935 // RETURNS: a JSON data stream representing the passed #GObject
1936 // <gobject>: a #GObject
1937 // <length>: return value for the length of the buffer, or %NULL
1938 static char* /*new*/ serialize_gobject(GObject2
.Object
* gobject
, /*out*/ size_t
* length
) {
1939 return json_serialize_gobject(gobject
, length
);
1946 Array
* /*new*/ json_array_new();
1947 Array
* /*new*/ json_array_sized_new(uint n_elements
);
1948 void json_array_add_array_element(Array
* this_
, Array
* value
);
1949 void json_array_add_boolean_element(Array
* this_
, int value
);
1950 void json_array_add_double_element(Array
* this_
, double value
);
1951 void json_array_add_element(Array
* this_
, Node
* node
);
1952 void json_array_add_int_element(Array
* this_
, long value
);
1953 void json_array_add_null_element(Array
* this_
);
1954 void json_array_add_object_element(Array
* this_
, Object
* value
);
1955 void json_array_add_string_element(Array
* this_
, char* value
);
1956 Node
* /*new*/ json_array_dup_element(Array
* this_
, uint index_
);
1957 void json_array_foreach_element(Array
* this_
, ArrayForeach func
, void* data
);
1958 Array
* json_array_get_array_element(Array
* this_
, uint index_
);
1959 int json_array_get_boolean_element(Array
* this_
, uint index_
);
1960 double json_array_get_double_element(Array
* this_
, uint index_
);
1961 Node
* json_array_get_element(Array
* this_
, uint index_
);
1962 GLib2
.List
* /*new container*/ json_array_get_elements(Array
* this_
);
1963 long json_array_get_int_element(Array
* this_
, uint index_
);
1964 uint json_array_get_length(Array
* this_
);
1965 int json_array_get_null_element(Array
* this_
, uint index_
);
1966 Object
* json_array_get_object_element(Array
* this_
, uint index_
);
1967 char* json_array_get_string_element(Array
* this_
, uint index_
);
1968 Array
* /*new*/ json_array_ref(Array
* this_
);
1969 void json_array_remove_element(Array
* this_
, uint index_
);
1970 void json_array_unref(Array
* this_
);
1971 Builder
* /*new*/ json_builder_new();
1972 Builder
* json_builder_add_boolean_value(Builder
* this_
, int value
);
1973 Builder
* json_builder_add_double_value(Builder
* this_
, double value
);
1974 Builder
* json_builder_add_int_value(Builder
* this_
, long value
);
1975 Builder
* json_builder_add_null_value(Builder
* this_
);
1976 Builder
* json_builder_add_string_value(Builder
* this_
, char* value
);
1977 Builder
* json_builder_add_value(Builder
* this_
, Node
* node
);
1978 Builder
* json_builder_begin_array(Builder
* this_
);
1979 Builder
* json_builder_begin_object(Builder
* this_
);
1980 Builder
* json_builder_end_array(Builder
* this_
);
1981 Builder
* json_builder_end_object(Builder
* this_
);
1982 Node
* /*new*/ json_builder_get_root(Builder
* this_
);
1983 void json_builder_reset(Builder
* this_
);
1984 Builder
* json_builder_set_member_name(Builder
* this_
, char* member_name
);
1985 Generator
* /*new*/ json_generator_new();
1986 uint json_generator_get_indent(Generator
* this_
);
1987 dchar json_generator_get_indent_char(Generator
* this_
);
1988 int json_generator_get_pretty(Generator
* this_
);
1989 Node
* json_generator_get_root(Generator
* this_
);
1990 void json_generator_set_indent(Generator
* this_
, uint indent_level
);
1991 void json_generator_set_indent_char(Generator
* this_
, dchar indent_char
);
1992 void json_generator_set_pretty(Generator
* this_
, int is_pretty
);
1993 void json_generator_set_root(Generator
* this_
, Node
* node
);
1994 char* /*new*/ json_generator_to_data(Generator
* this_
, /*out*/ size_t
* length
);
1995 int json_generator_to_file(Generator
* this_
, char* filename
, GLib2
.Error
** error
);
1996 int json_generator_to_stream(Generator
* this_
, Gio2
.OutputStream
* stream
, Gio2
.Cancellable
* cancellable
, GLib2
.Error
** error
);
1997 Node
* /*new*/ json_node_new(NodeType type
);
1998 Node
* /*new*/ json_node_copy(Node
* this_
);
1999 Array
* /*new*/ json_node_dup_array(Node
* this_
);
2000 Object
* /*new*/ json_node_dup_object(Node
* this_
);
2001 char* /*new*/ json_node_dup_string(Node
* this_
);
2002 void json_node_free(Node
* this_
);
2003 Array
* json_node_get_array(Node
* this_
);
2004 int json_node_get_boolean(Node
* this_
);
2005 double json_node_get_double(Node
* this_
);
2006 long json_node_get_int(Node
* this_
);
2007 NodeType
json_node_get_node_type(Node
* this_
);
2008 Object
* json_node_get_object(Node
* this_
);
2009 Node
* json_node_get_parent(Node
* this_
);
2010 char* json_node_get_string(Node
* this_
);
2011 void json_node_get_value(Node
* this_
, /*out*/ GObject2
.Value
* value
);
2012 Type
json_node_get_value_type(Node
* this_
);
2013 int json_node_is_null(Node
* this_
);
2014 void json_node_set_array(Node
* this_
, Array
* array
);
2015 void json_node_set_boolean(Node
* this_
, int value
);
2016 void json_node_set_double(Node
* this_
, double value
);
2017 void json_node_set_int(Node
* this_
, long value
);
2018 void json_node_set_object(Node
* this_
, Object
* object
);
2019 void json_node_set_parent(Node
* this_
, Node
* parent
);
2020 void json_node_set_string(Node
* this_
, char* value
);
2021 void json_node_set_value(Node
* this_
, GObject2
.Value
* value
);
2022 void json_node_take_array(Node
* this_
, Array
* array
);
2023 void json_node_take_object(Node
* this_
, Object
* object
);
2024 char* json_node_type_name(Node
* this_
);
2025 Object
* /*new*/ json_object_new();
2026 void json_object_add_member(Object
* this_
, char* member_name
, Node
* node
);
2027 Node
* /*new*/ json_object_dup_member(Object
* this_
, char* member_name
);
2028 void json_object_foreach_member(Object
* this_
, ObjectForeach func
, void* data
);
2029 Array
* json_object_get_array_member(Object
* this_
, char* member_name
);
2030 int json_object_get_boolean_member(Object
* this_
, char* member_name
);
2031 double json_object_get_double_member(Object
* this_
, char* member_name
);
2032 long json_object_get_int_member(Object
* this_
, char* member_name
);
2033 Node
* json_object_get_member(Object
* this_
, char* member_name
);
2034 GLib2
.List
* /*new container*/ json_object_get_members(Object
* this_
);
2035 int json_object_get_null_member(Object
* this_
, char* member_name
);
2036 Object
* json_object_get_object_member(Object
* this_
, char* member_name
);
2037 uint json_object_get_size(Object
* this_
);
2038 char* json_object_get_string_member(Object
* this_
, char* member_name
);
2039 GLib2
.List
* /*new container*/ json_object_get_values(Object
* this_
);
2040 int json_object_has_member(Object
* this_
, char* member_name
);
2041 Object
* /*new*/ json_object_ref(Object
* this_
);
2042 void json_object_remove_member(Object
* this_
, char* member_name
);
2043 void json_object_set_array_member(Object
* this_
, char* member_name
, Array
* value
);
2044 void json_object_set_boolean_member(Object
* this_
, char* member_name
, int value
);
2045 void json_object_set_double_member(Object
* this_
, char* member_name
, double value
);
2046 void json_object_set_int_member(Object
* this_
, char* member_name
, long value
);
2047 void json_object_set_member(Object
* this_
, char* member_name
, Node
* node
);
2048 void json_object_set_null_member(Object
* this_
, char* member_name
);
2049 void json_object_set_object_member(Object
* this_
, char* member_name
, Object
* value
);
2050 void json_object_set_string_member(Object
* this_
, char* member_name
, char* value
);
2051 void json_object_unref(Object
* this_
);
2052 Parser
* /*new*/ json_parser_new();
2053 GLib2
.Quark
json_parser_error_quark();
2054 uint json_parser_get_current_line(Parser
* this_
);
2055 uint json_parser_get_current_pos(Parser
* this_
);
2056 Node
* json_parser_get_root(Parser
* this_
);
2057 int json_parser_has_assignment(Parser
* this_
, /*out*/ char** variable_name
=null);
2058 int json_parser_load_from_data(Parser
* this_
, char* data
, ssize_t length
, GLib2
.Error
** error
);
2059 int json_parser_load_from_file(Parser
* this_
, char* filename
, GLib2
.Error
** error
);
2060 int json_parser_load_from_stream(Parser
* this_
, Gio2
.InputStream
* stream
, Gio2
.Cancellable
* cancellable
, GLib2
.Error
** error
);
2061 void json_parser_load_from_stream_async(Parser
* this_
, Gio2
.InputStream
* stream
, Gio2
.Cancellable
* cancellable
, Gio2
.AsyncReadyCallback callback
, void* user_data
);
2062 int json_parser_load_from_stream_finish(Parser
* this_
, Gio2
.AsyncResult
* result
, GLib2
.Error
** error
);
2063 Path
* /*new*/ json_path_new();
2064 GLib2
.Quark
json_path_error_quark();
2065 Node
* /*new*/ json_path_query(char* expression
, Node
* root
, GLib2
.Error
** error
);
2066 int json_path_compile(Path
* this_
, char* expression
, GLib2
.Error
** error
);
2067 Node
* /*new*/ json_path_match(Path
* this_
, Node
* root
);
2068 Reader
* /*new*/ json_reader_new(Node
* node
=null);
2069 GLib2
.Quark
json_reader_error_quark();
2070 int json_reader_count_elements(Reader
* this_
);
2071 int json_reader_count_members(Reader
* this_
);
2072 void json_reader_end_element(Reader
* this_
);
2073 void json_reader_end_member(Reader
* this_
);
2074 int json_reader_get_boolean_value(Reader
* this_
);
2075 double json_reader_get_double_value(Reader
* this_
);
2076 GLib2
.Error
* json_reader_get_error(Reader
* this_
);
2077 long json_reader_get_int_value(Reader
* this_
);
2078 char* json_reader_get_member_name(Reader
* this_
);
2079 int json_reader_get_null_value(Reader
* this_
);
2080 char* json_reader_get_string_value(Reader
* this_
);
2081 Node
* json_reader_get_value(Reader
* this_
);
2082 int json_reader_is_array(Reader
* this_
);
2083 int json_reader_is_object(Reader
* this_
);
2084 int json_reader_is_value(Reader
* this_
);
2085 char** /*new*/ json_reader_list_members(Reader
* this_
);
2086 int json_reader_read_element(Reader
* this_
, uint index_
);
2087 int json_reader_read_member(Reader
* this_
, char* member_name
);
2088 void json_reader_set_root(Reader
* this_
, Node
* root
=null);
2089 int json_serializable_default_deserialize_property(Serializable
* this_
, char* property_name
, GObject2
.Value
* value
, GObject2
.ParamSpec
* pspec
, Node
* property_node
);
2090 Node
* /*new*/ json_serializable_default_serialize_property(Serializable
* this_
, char* property_name
, GObject2
.Value
* value
, GObject2
.ParamSpec
* pspec
);
2091 int json_serializable_deserialize_property(Serializable
* this_
, char* property_name
, /*out*/ GObject2
.Value
* value
, GObject2
.ParamSpec
* pspec
, Node
* property_node
);
2092 GObject2
.ParamSpec
* json_serializable_find_property(Serializable
* this_
, char* name
);
2093 void json_serializable_get_property(Serializable
* this_
, GObject2
.ParamSpec
* pspec
, GObject2
.Value
* value
);
2094 GObject2
.ParamSpec
** /*new container*/ json_serializable_list_properties(Serializable
* this_
, /*out*/ uint* n_pspecs
);
2095 Node
* /*new*/ json_serializable_serialize_property(Serializable
* this_
, char* property_name
, GObject2
.Value
* value
, GObject2
.ParamSpec
* pspec
);
2096 void json_serializable_set_property(Serializable
* this_
, GObject2
.ParamSpec
* pspec
, GObject2
.Value
* value
);
2097 int json_boxed_can_deserialize(Type gboxed_type
, NodeType node_type
);
2098 int json_boxed_can_serialize(Type gboxed_type
, /*out*/ NodeType
* node_type
);
2099 void* /*new*/ json_boxed_deserialize(Type gboxed_type
, Node
* node
);
2100 void json_boxed_register_deserialize_func(Type gboxed_type
, NodeType node_type
, BoxedDeserializeFunc deserialize_func
);
2101 void json_boxed_register_serialize_func(Type gboxed_type
, NodeType node_type
, BoxedSerializeFunc serialize_func
);
2102 Node
* /*new*/ json_boxed_serialize(Type gboxed_type
, const(void)* boxed
);
2103 GObject2
.Object
* /*new*/ json_construct_gobject(Type gtype
, char* data
, size_t length
, GLib2
.Error
** error
);
2104 GObject2
.Object
* /*new*/ json_gobject_deserialize(Type gtype
, Node
* node
);
2105 GObject2
.Object
* /*new*/ json_gobject_from_data(Type gtype
, char* data
, ssize_t length
, GLib2
.Error
** error
);
2106 Node
* /*new*/ json_gobject_serialize(GObject2
.Object
* gobject
);
2107 char* /*new*/ json_gobject_to_data(GObject2
.Object
* gobject
, /*out*/ size_t
* length
);
2108 GLib2
.Variant
* /*new*/ json_gvariant_deserialize(Node
* json_node
, char* signature
, GLib2
.Error
** error
);
2109 GLib2
.Variant
* /*new*/ json_gvariant_deserialize_data(char* json
, ssize_t length
, char* signature
, GLib2
.Error
** error
);
2110 Node
* /*new*/ json_gvariant_serialize(GLib2
.Variant
* variant
);
2111 char* /*new*/ json_gvariant_serialize_data(GLib2
.Variant
* variant
, /*out*/ size_t
* length
=null);
2112 char* /*new*/ json_serialize_gobject(GObject2
.Object
* gobject
, /*out*/ size_t
* length
);