@girs/json-1.0 1.7.1-3.0.0-beta.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/json-1.0.d.ts ADDED
@@ -0,0 +1,3409 @@
1
+
2
+ /*
3
+ * Type Definitions for Gjs (https://gjs.guide/)
4
+ *
5
+ * These type definitions are automatically generated, do not edit them by hand.
6
+ * If you found a bug fix it in `ts-for-gir` or create a bug report on https://github.com/gjsify/ts-for-gjs
7
+ */
8
+ /**
9
+ * Json-1.0
10
+ */
11
+
12
+ import type Gio from '@girs/gio-2.0';
13
+ import type GObject from '@girs/gobject-2.0';
14
+ import type GLib from '@girs/glib-2.0';
15
+
16
+ export namespace Json {
17
+
18
+ /**
19
+ * Indicates the content of a node.
20
+ */
21
+ enum NodeType {
22
+ /**
23
+ * The node contains a JSON object
24
+ */
25
+ OBJECT,
26
+ /**
27
+ * The node contains a JSON array
28
+ */
29
+ ARRAY,
30
+ /**
31
+ * The node contains a fundamental type
32
+ */
33
+ VALUE,
34
+ /**
35
+ * Special type, for nodes containing null
36
+ */
37
+ NULL,
38
+ }
39
+ /**
40
+ * Error codes for `JSON_PARSER_ERROR`.
41
+ *
42
+ * This enumeration can be extended at later date
43
+ */
44
+ enum ParserError {
45
+ /**
46
+ * parse error
47
+ */
48
+ PARSE,
49
+ /**
50
+ * unexpected trailing comma
51
+ */
52
+ TRAILING_COMMA,
53
+ /**
54
+ * expected comma
55
+ */
56
+ MISSING_COMMA,
57
+ /**
58
+ * expected colon
59
+ */
60
+ MISSING_COLON,
61
+ /**
62
+ * invalid bareword
63
+ */
64
+ INVALID_BAREWORD,
65
+ /**
66
+ * empty member name (Since: 0.16)
67
+ */
68
+ EMPTY_MEMBER_NAME,
69
+ /**
70
+ * invalid data (Since: 0.18)
71
+ */
72
+ INVALID_DATA,
73
+ /**
74
+ * unknown error
75
+ */
76
+ UNKNOWN,
77
+ }
78
+ /**
79
+ * Error codes for `JSON_PATH_ERROR`.
80
+ *
81
+ * This enumeration can be extended at later date
82
+ */
83
+ enum PathError {
84
+ /**
85
+ * Invalid query
86
+ */
87
+ QUERY,
88
+ }
89
+ /**
90
+ * Error codes for `JSON_READER_ERROR`.
91
+ *
92
+ * This enumeration can be extended at later date
93
+ */
94
+ enum ReaderError {
95
+ /**
96
+ * No array found at the current position
97
+ */
98
+ NO_ARRAY,
99
+ /**
100
+ * Index out of bounds
101
+ */
102
+ INVALID_INDEX,
103
+ /**
104
+ * No object found at the current position
105
+ */
106
+ NO_OBJECT,
107
+ /**
108
+ * Member not found
109
+ */
110
+ INVALID_MEMBER,
111
+ /**
112
+ * No valid node found at the current position
113
+ */
114
+ INVALID_NODE,
115
+ /**
116
+ * The node at the current position does not
117
+ * hold a value
118
+ */
119
+ NO_VALUE,
120
+ /**
121
+ * The node at the current position does not
122
+ * hold a value of the desired type
123
+ */
124
+ INVALID_TYPE,
125
+ }
126
+ /**
127
+ * Json major version component (e.g. 1 if `JSON_VERSION` is "1.2.3")
128
+ */
129
+ const MAJOR_VERSION: number
130
+ /**
131
+ * Json micro version component (e.g. 3 if `JSON_VERSION` is "1.2.3")
132
+ */
133
+ const MICRO_VERSION: number
134
+ /**
135
+ * Json minor version component (e.g. 2 if `JSON_VERSION` is "1.2.3")
136
+ */
137
+ const MINOR_VERSION: number
138
+ /**
139
+ * The version of JSON-GLib, encoded as a string, useful for printing and
140
+ * concatenation.
141
+ */
142
+ const VERSION_S: string | null
143
+ /**
144
+ * Checks whether it is possible to deserialize a `GBoxed` of
145
+ * type `gboxed_type` from a [struct`Json`.Node] of type `node_type`.
146
+ * @param gboxed_type a boxed type
147
+ * @param node_type a node type
148
+ * @returns `TRUE` if the type can be deserialized, and `FALSE` otherwise
149
+ */
150
+ function boxed_can_deserialize(gboxed_type: GObject.GType, node_type: NodeType): boolean
151
+ /**
152
+ * Checks whether it is possible to serialize a `GBoxed` of
153
+ * type `gboxed_type` into a [struct`Json`.Node].
154
+ *
155
+ * The type of the node is placed inside `node_type` if the function
156
+ * returns `TRUE`, and it's undefined otherwise.
157
+ * @param gboxed_type a boxed type
158
+ * @returns `TRUE` if the type can be serialized, and `FALSE` otherwise
159
+ */
160
+ function boxed_can_serialize(gboxed_type: GObject.GType): [ /* returnType */ boolean, /* node_type */ NodeType ]
161
+ /**
162
+ * Deserializes the given [struct`Json`.Node] into a `GBoxed` of the given type.
163
+ * @param gboxed_type a boxed type
164
+ * @param node a node
165
+ * @returns the newly allocated boxed data
166
+ */
167
+ function boxed_deserialize(gboxed_type: GObject.GType, node: Node): any | null
168
+ /**
169
+ * Serializes a pointer to a `GBoxed` of the given type into a [struct`Json`.Node].
170
+ *
171
+ * If the serialization is not possible, this function will return `NULL`.
172
+ * @param gboxed_type a boxed type
173
+ * @param boxed a pointer to a boxed of type `gboxed_type`
174
+ * @returns a node with the serialized boxed type
175
+ */
176
+ function boxed_serialize(gboxed_type: GObject.GType, boxed: any | null): Node | null
177
+ /**
178
+ * Deserializes a JSON data stream and creates an instance of the given
179
+ * type.
180
+ *
181
+ * If the given type implements the [iface`Json`.Serializable] interface, it
182
+ * will be asked to deserialize all the JSON members into their respective
183
+ * properties; otherwise, the default implementation will be used to translate
184
+ * the compatible JSON native types.
185
+ *
186
+ * **Note**: the JSON data stream must be an object.
187
+ *
188
+ * For historical reasons, the `length` argument is unused. The given `data`
189
+ * must be a `NUL`-terminated string.
190
+ * @param gtype the type of the object to construct
191
+ * @param data a JSON data stream
192
+ * @param length length of the data stream (unused)
193
+ * @returns a new object instance of the given type
194
+ */
195
+ function construct_gobject(gtype: GObject.GType, data: string | null, length: number): GObject.Object | null
196
+ /**
197
+ * Parses the given string and returns the corresponding JSON tree.
198
+ *
199
+ * If the string is empty, this function will return `NULL`.
200
+ *
201
+ * In case of parsing error, this function returns `NULL` and sets
202
+ * the error appropriately.
203
+ * @param str a valid UTF-8 string containing JSON data
204
+ * @returns the root node of the JSON tree
205
+ */
206
+ function from_string(str: string | null): Node | null
207
+ /**
208
+ * Creates a new `GObject` instance of the given type, and constructs it
209
+ * using the members of the object in the given node.
210
+ * @param gtype the type of the object to create
211
+ * @param node a node of type `JSON_NODE_OBJECT` describing the object instance for the given type
212
+ * @returns The newly created instance
213
+ */
214
+ function gobject_deserialize(gtype: GObject.GType, node: Node): GObject.Object
215
+ /**
216
+ * Deserializes a JSON data stream and creates an instance of the
217
+ * given type.
218
+ *
219
+ * If the type implements the [iface`Json`.Serializable] interface, it will
220
+ * be asked to deserialize all the JSON members into their respective properties;
221
+ * otherwise, the default implementation will be used to translate the
222
+ * compatible JSON native types.
223
+ *
224
+ * **Note**: the JSON data stream must be an object
225
+ * @param gtype the type of the object to construct
226
+ * @param data a JSON data stream
227
+ * @param length length of the data stream, or -1 if it is `NUL`-terminated
228
+ * @returns a new object instance of the given type
229
+ */
230
+ function gobject_from_data(gtype: GObject.GType, data: string | null, length: number): GObject.Object | null
231
+ /**
232
+ * Creates a JSON tree representing the passed object instance.
233
+ *
234
+ * Each member of the returned JSON object will map to a property of
235
+ * the object type.
236
+ *
237
+ * The returned JSON tree will be returned as a `JsonNode` with a type
238
+ * of `JSON_NODE_OBJECT`.
239
+ * @param gobject the object to serialize
240
+ * @returns the newly created JSON tree
241
+ */
242
+ function gobject_serialize(gobject: GObject.Object): Node
243
+ /**
244
+ * Serializes a `GObject` instance into a JSON data stream, iterating
245
+ * recursively over each property.
246
+ *
247
+ * If the given object implements the [iface`Json`.Serializable] interface,
248
+ * it will be asked to serialize all its properties; otherwise, the default
249
+ * implementation will be use to translate the compatible types into
250
+ * JSON native types.
251
+ * @param gobject the object to serialize
252
+ * @returns a JSON data stream representing the given object
253
+ */
254
+ function gobject_to_data(gobject: GObject.Object): [ /* returnType */ string | null, /* length */ number ]
255
+ /**
256
+ * Converts a JSON data structure to a `GVariant`.
257
+ *
258
+ * If `signature` is not `NULL`, it will be used to resolve ambiguous
259
+ * data types.
260
+ *
261
+ * If no error occurs, the resulting `GVariant` is guaranteed to conform
262
+ * to `signature`.
263
+ *
264
+ * If `signature` is not `NULL` but does not represent a valid `GVariant` type
265
+ * string, `NULL` is returned and the `error` is set to
266
+ * `G_IO_ERROR_INVALID_ARGUMENT`.
267
+ *
268
+ * If a `signature` is provided but the JSON structure cannot be mapped to it,
269
+ * `NULL` is returned and the `error` is set to `G_IO_ERROR_INVALID_DATA`.
270
+ *
271
+ * If `signature` is `NULL`, the conversion is done based strictly on the types
272
+ * in the JSON nodes.
273
+ *
274
+ * The returned variant has a floating reference that will need to be sunk
275
+ * by the caller code.
276
+ * @param json_node the node to convert
277
+ * @param signature a valid `GVariant` type string
278
+ * @returns A newly created `GVariant`
279
+ */
280
+ function gvariant_deserialize(json_node: Node, signature: string | null): GLib.Variant | null
281
+ /**
282
+ * Converts a JSON string to a `GVariant` value.
283
+ *
284
+ * This function works exactly like [func`Json`.gvariant_deserialize], but
285
+ * takes a JSON encoded string instead.
286
+ *
287
+ * The string is first converted to a [struct`Json`.Node] using
288
+ * [class`Json`.Parser], and then `json_gvariant_deserialize` is called on
289
+ * the node.
290
+ *
291
+ * The returned variant has a floating reference that will need to be sunk
292
+ * by the caller code.
293
+ * @param json A JSON data string
294
+ * @param length The length of `json,` or -1 if `NUL`-terminated
295
+ * @param signature A valid `GVariant` type string
296
+ * @returns A newly created `GVariant`D compliant
297
+ */
298
+ function gvariant_deserialize_data(json: string | null, length: number, signature: string | null): GLib.Variant | null
299
+ /**
300
+ * Converts `variant` to a JSON tree.
301
+ * @param variant A `GVariant` to convert
302
+ * @returns the root of the JSON data structure obtained from `variant`
303
+ */
304
+ function gvariant_serialize(variant: GLib.Variant): Node
305
+ /**
306
+ * Converts `variant` to its JSON encoded string representation.
307
+ *
308
+ * This is a convenience function around [func`Json`.gvariant_serialize], to
309
+ * obtain the JSON tree, and then [class`Json`.Generator] to stringify it.
310
+ * @param variant A #GVariant to convert
311
+ * @returns The JSON encoded string corresponding to the given variant
312
+ */
313
+ function gvariant_serialize_data(variant: GLib.Variant): [ /* returnType */ string | null, /* length */ number ]
314
+ function parser_error_quark(): GLib.Quark
315
+ function path_error_quark(): GLib.Quark
316
+ function reader_error_quark(): GLib.Quark
317
+ /**
318
+ * Serializes a `GObject` instance into a JSON data stream.
319
+ *
320
+ * If the object implements the [iface`Json`.Serializable] interface, it will be
321
+ * asked to serizalize all its properties; otherwise, the default
322
+ * implementation will be use to translate the compatible types into JSON
323
+ * native types.
324
+ * @param gobject the object to serialize
325
+ * @returns a JSON data stream representing the given object
326
+ */
327
+ function serialize_gobject(gobject: GObject.Object): [ /* returnType */ string | null, /* length */ number ]
328
+ /**
329
+ * Check whether `a` and `b` are equal UTF-8 JSON strings and return an ordering
330
+ * over them in `strcmp()` style.
331
+ * @param a a JSON string
332
+ * @param b another JSON string
333
+ * @returns an integer less than zero if `a < b`, equal to zero if `a == b`, and greater than zero if `a > b`
334
+ */
335
+ function string_compare(a: string, b: string): number
336
+ /**
337
+ * Check whether `a` and `b` are equal UTF-8 JSON strings.
338
+ * @param a a JSON string
339
+ * @param b another JSON string
340
+ * @returns `TRUE` if @a and @b are equal; `FALSE` otherwise
341
+ */
342
+ function string_equal(a: string, b: string): boolean
343
+ /**
344
+ * Calculate a hash value for the given `key` (a UTF-8 JSON string).
345
+ *
346
+ * Note: Member names are compared byte-wise, without applying any Unicode
347
+ * decomposition or normalisation. This is not explicitly mentioned in the JSON
348
+ * standard (ECMA-404), but is assumed.
349
+ * @param key a JSON string to hash
350
+ * @returns hash value for @key
351
+ */
352
+ function string_hash(key: string): number
353
+ /**
354
+ * Generates a stringified JSON representation of the contents of
355
+ * the given `node`.
356
+ * @param node a JSON tree
357
+ * @param pretty whether the output should be prettyfied for printing
358
+ * @returns the string representation of the node
359
+ */
360
+ function to_string(node: Node, pretty: boolean): string | null
361
+ /**
362
+ * The function to be passed to [method`Json`.Array.foreach_element].
363
+ *
364
+ * You should not add or remove elements to and from `array` within
365
+ * this function.
366
+ *
367
+ * It is safe to change the value of `element_node`.
368
+ * @callback
369
+ * @param array the iterated JSON array
370
+ * @param index_ the index of the element
371
+ * @param element_node the value of the element at the given `index_`
372
+ */
373
+ interface ArrayForeach {
374
+ (array: Array, index_: number, element_node: Node): void
375
+ }
376
+ /**
377
+ * Deserializes the contents of the passed `JsonNode` into a `GBoxed`, for instance:
378
+ *
379
+ * ```c
380
+ * static gpointer
381
+ * my_point_deserialize (JsonNode *node)
382
+ * {
383
+ * double x = 0.0, y = 0.0;
384
+ *
385
+ * if (JSON_NODE_HOLDS_ARRAY (node))
386
+ * {
387
+ * JsonArray *array = json_node_get_array (node);
388
+ *
389
+ * if (json_array_get_length (array) == 2)
390
+ * {
391
+ * x = json_array_get_double_element (array, 0);
392
+ * y = json_array_get_double_element (array, 1);
393
+ * }
394
+ * }
395
+ * else if (JSON_NODE_HOLDS_OBJECT (node))
396
+ * {
397
+ * JsonObject *obj = json_node_get_object (node);
398
+ *
399
+ * x = json_object_get_double_member_with_default (obj, "x", 0.0);
400
+ * y = json_object_get_double_member_with_default (obj, "y", 0.0);
401
+ * }
402
+ *
403
+ * // my_point_new() is defined elsewhere
404
+ * return my_point_new (x, y);
405
+ * }
406
+ * ```
407
+ * @callback
408
+ * @param node a node tree representing a boxed data
409
+ * @returns the newly created boxed structure
410
+ */
411
+ interface BoxedDeserializeFunc {
412
+ (node: Node): any | null
413
+ }
414
+ /**
415
+ * Serializes the passed `GBoxed` and stores it inside a `JsonNode`, for instance:
416
+ *
417
+ * ```c
418
+ * static JsonNode *
419
+ * my_point_serialize (gconstpointer boxed)
420
+ * {
421
+ * const MyPoint *point = boxed;
422
+ *
423
+ * g_autoptr(JsonBuilder) builder = json_builder_new ();
424
+ *
425
+ * json_builder_begin_object (builder);
426
+ * json_builder_set_member_name (builder, "x");
427
+ * json_builder_add_double_value (builder, point->x);
428
+ * json_builder_set_member_name (builder, "y");
429
+ * json_builder_add_double_value (builder, point->y);
430
+ * json_builder_end_object (builder);
431
+ *
432
+ * return json_builder_get_root (builder);
433
+ * }
434
+ * ```
435
+ * @callback
436
+ * @param boxed a boxed data structure
437
+ * @returns the newly created JSON node tree representing the boxed data
438
+ */
439
+ interface BoxedSerializeFunc {
440
+ (boxed: any | null): Node
441
+ }
442
+ /**
443
+ * The function to be passed to [method`Json`.Object.foreach_member].
444
+ *
445
+ * You should not add or remove members to and from `object` within
446
+ * this function.
447
+ *
448
+ * It is safe to change the value of `member_node`.
449
+ * @callback
450
+ * @param object the iterated JSON object
451
+ * @param member_name the name of the member
452
+ * @param member_node the value of the member
453
+ */
454
+ interface ObjectForeach {
455
+ (object: Object, member_name: string | null, member_node: Node): void
456
+ }
457
+ module Serializable {
458
+
459
+ // Constructor properties interface
460
+
461
+ interface ConstructorProperties extends GObject.Object.ConstructorProperties {
462
+ }
463
+
464
+ }
465
+
466
+ interface Serializable {
467
+
468
+ // Owm methods of Json-1.0.Json.Serializable
469
+
470
+ /**
471
+ * Calls the default implementation of the [vfunc`Json`.Serializable.deserialize_property]
472
+ * virtual function.
473
+ *
474
+ * This function can be used inside a custom implementation of the
475
+ * `deserialize_property()` virtual function in lieu of calling the
476
+ * default implementation through `g_type_default_interface_peek()`:
477
+ *
478
+ * ```c
479
+ * JsonSerializable *iface;
480
+ * gboolean res;
481
+ *
482
+ * iface = g_type_default_interface_peek (JSON_TYPE_SERIALIZABLE);
483
+ * res = iface->deserialize_property (serializable, property_name,
484
+ * value,
485
+ * pspec,
486
+ * property_node);
487
+ * ```
488
+ * @param property_name the name of the property to deserialize
489
+ * @param value a pointer to an uninitialized value
490
+ * @param pspec a property description
491
+ * @param property_node the JSON node containing the serialized property
492
+ * @returns `TRUE` if the property was successfully deserialized
493
+ */
494
+ default_deserialize_property(property_name: string | null, value: any, pspec: GObject.ParamSpec, property_node: Node): boolean
495
+ /**
496
+ * Calls the default implementation of the [vfunc`Json`.Serializable.serialize_property]
497
+ * virtual function.
498
+ *
499
+ * This function can be used inside a custom implementation of the
500
+ * `serialize_property()` virtual function in lieu of calling the
501
+ * default implementation through `g_type_default_interface_peek()`:
502
+ *
503
+ * ```c
504
+ * JsonSerializable *iface;
505
+ * JsonNode *node;
506
+ *
507
+ * iface = g_type_default_interface_peek (JSON_TYPE_SERIALIZABLE);
508
+ * node = iface->serialize_property (serializable, property_name,
509
+ * value,
510
+ * pspec);
511
+ * ```
512
+ *
513
+ * This function will return `NULL` if the property could not be
514
+ * serialized.
515
+ * @param property_name the name of the property to serialize
516
+ * @param value the value of the property to serialize
517
+ * @param pspec a property description
518
+ * @returns a node containing the serialized property
519
+ */
520
+ default_serialize_property(property_name: string | null, value: any, pspec: GObject.ParamSpec): Node | null
521
+ /**
522
+ * Asks a `JsonSerializable` implementation to deserialize the
523
+ * property contained inside `property_node` and place its value
524
+ * into `value`.
525
+ *
526
+ * The `value` can be:
527
+ *
528
+ * - an empty `GValue` initialized by `G_VALUE_INIT`, which will be automatically
529
+ * initialized with the expected type of the property by using the given
530
+ * property description (since JSON-GLib 1.6)
531
+ * - a `GValue` initialized with the expected type of the property
532
+ *
533
+ * This function will not be called for properties that are marked as
534
+ * as `G_PARAM_CONSTRUCT_ONLY`.
535
+ * @param property_name the name of the property to serialize
536
+ * @param pspec a property description
537
+ * @param property_node the JSON node containing the serialized property
538
+ * @returns `TRUE` if the property was successfully deserialized
539
+ */
540
+ deserialize_property(property_name: string | null, pspec: GObject.ParamSpec, property_node: Node): [ /* returnType */ boolean, /* value */ any ]
541
+ /**
542
+ * Calls the [vfunc`Json`.Serializable.find_property] implementation on
543
+ * the `JsonSerializable` instance, which will return the property
544
+ * description for the given name.
545
+ * @param name the name of the property
546
+ * @returns the property description
547
+ */
548
+ find_property(name: string | null): GObject.ParamSpec | null
549
+ /**
550
+ * Calls the [vfunc`Json`.Serializable.get_property] implementation
551
+ * on the `JsonSerializable` instance, which will get the value of
552
+ * the given property.
553
+ * @param pspec a property description
554
+ */
555
+ get_property(pspec: GObject.ParamSpec): /* value */ any
556
+
557
+ // Overloads of get_property
558
+
559
+ /**
560
+ * Gets a property of an object.
561
+ *
562
+ * The `value` can be:
563
+ *
564
+ * - an empty #GValue initialized by %G_VALUE_INIT, which will be
565
+ * automatically initialized with the expected type of the property
566
+ * (since GLib 2.60)
567
+ * - a #GValue initialized with the expected type of the property
568
+ * - a #GValue initialized with a type to which the expected type
569
+ * of the property can be transformed
570
+ *
571
+ * In general, a copy is made of the property contents and the caller is
572
+ * responsible for freeing the memory by calling g_value_unset().
573
+ *
574
+ * Note that g_object_get_property() is really intended for language
575
+ * bindings, g_object_get() is much more convenient for C programming.
576
+ * @param property_name the name of the property to get
577
+ * @param value return location for the property value
578
+ */
579
+ get_property(property_name: string | null, value: any): void
580
+ /**
581
+ * Calls the [vfunc`Json`.Serializable.list_properties] implementation on
582
+ * the `JsonSerializable` instance, which will return the list of serializable
583
+ * properties.
584
+ * @returns the serializable properties of the object
585
+ */
586
+ list_properties(): GObject.ParamSpec[]
587
+ /**
588
+ * Asks a `JsonSerializable` implementation to serialize an object
589
+ * property into a JSON node.
590
+ * @param property_name the name of the property to serialize
591
+ * @param value the value of the property to serialize
592
+ * @param pspec a property description
593
+ * @returns a node containing the serialized property
594
+ */
595
+ serialize_property(property_name: string | null, value: any, pspec: GObject.ParamSpec): Node
596
+ /**
597
+ * Calls the [vfunc`Json`.Serializable.set_property] implementation
598
+ * on the `JsonSerializable` instance, which will set the property
599
+ * with the given value.
600
+ * @param pspec a property description
601
+ * @param value the property value to set
602
+ */
603
+ set_property(pspec: GObject.ParamSpec, value: any): void
604
+
605
+ // Overloads of set_property
606
+
607
+ /**
608
+ * Sets a property on an object.
609
+ * @param property_name the name of the property to set
610
+ * @param value the value
611
+ */
612
+ set_property(property_name: string | null, value: any): void
613
+
614
+ // Own virtual methods of Json-1.0.Json.Serializable
615
+
616
+ /**
617
+ * Asks a `JsonSerializable` implementation to deserialize the
618
+ * property contained inside `property_node` and place its value
619
+ * into `value`.
620
+ *
621
+ * The `value` can be:
622
+ *
623
+ * - an empty `GValue` initialized by `G_VALUE_INIT`, which will be automatically
624
+ * initialized with the expected type of the property by using the given
625
+ * property description (since JSON-GLib 1.6)
626
+ * - a `GValue` initialized with the expected type of the property
627
+ *
628
+ * This function will not be called for properties that are marked as
629
+ * as `G_PARAM_CONSTRUCT_ONLY`.
630
+ * @virtual
631
+ * @param property_name the name of the property to serialize
632
+ * @param pspec a property description
633
+ * @param property_node the JSON node containing the serialized property
634
+ * @returns `TRUE` if the property was successfully deserialized
635
+ */
636
+ vfunc_deserialize_property(property_name: string | null, pspec: GObject.ParamSpec, property_node: Node): [ /* returnType */ boolean, /* value */ any ]
637
+ /**
638
+ * Calls the [vfunc`Json`.Serializable.find_property] implementation on
639
+ * the `JsonSerializable` instance, which will return the property
640
+ * description for the given name.
641
+ * @virtual
642
+ * @param name the name of the property
643
+ * @returns the property description
644
+ */
645
+ vfunc_find_property(name: string | null): GObject.ParamSpec | null
646
+ /**
647
+ * Calls the [vfunc`Json`.Serializable.get_property] implementation
648
+ * on the `JsonSerializable` instance, which will get the value of
649
+ * the given property.
650
+ * @virtual
651
+ * @param pspec a property description
652
+ */
653
+ vfunc_get_property(pspec: GObject.ParamSpec): /* value */ any
654
+
655
+ // Overloads of vfunc_get_property
656
+
657
+ vfunc_get_property(property_id: number, value: any, pspec: GObject.ParamSpec): void
658
+ /**
659
+ * Asks a `JsonSerializable` implementation to serialize an object
660
+ * property into a JSON node.
661
+ * @virtual
662
+ * @param property_name the name of the property to serialize
663
+ * @param value the value of the property to serialize
664
+ * @param pspec a property description
665
+ * @returns a node containing the serialized property
666
+ */
667
+ vfunc_serialize_property(property_name: string | null, value: any, pspec: GObject.ParamSpec): Node
668
+ /**
669
+ * Calls the [vfunc`Json`.Serializable.set_property] implementation
670
+ * on the `JsonSerializable` instance, which will set the property
671
+ * with the given value.
672
+ * @virtual
673
+ * @param pspec a property description
674
+ * @param value the property value to set
675
+ */
676
+ vfunc_set_property(pspec: GObject.ParamSpec, value: any): void
677
+
678
+ // Overloads of vfunc_set_property
679
+
680
+ vfunc_set_property(property_id: number, value: any, pspec: GObject.ParamSpec): void
681
+
682
+ // Class property signals of Json-1.0.Json.Serializable
683
+
684
+ connect(sigName: string, callback: (...args: any[]) => void): number
685
+ connect_after(sigName: string, callback: (...args: any[]) => void): number
686
+ emit(sigName: string, ...args: any[]): void
687
+ disconnect(id: number): void
688
+ }
689
+
690
+ /**
691
+ * `JsonSerializable` is an interface for controlling the serialization
692
+ * and deserialization of `GObject` classes.
693
+ *
694
+ * Implementing this interface allows controlling how the class is going
695
+ * to be serialized or deserialized by [func`Json`.construct_gobject] and
696
+ * [func`Json`.serialize_gobject], respectively.
697
+ * @interface
698
+ */
699
+ class Serializable extends GObject.Object {
700
+
701
+ // Own properties of Json-1.0.Json.Serializable
702
+
703
+ static name: string
704
+ static $gtype: GObject.GType<Serializable>
705
+
706
+ // Constructors of Json-1.0.Json.Serializable
707
+
708
+ constructor(config?: Serializable.ConstructorProperties)
709
+ _init(config?: Serializable.ConstructorProperties): void
710
+ }
711
+
712
+ module Builder {
713
+
714
+ // Constructor properties interface
715
+
716
+ interface ConstructorProperties extends GObject.Object.ConstructorProperties {
717
+
718
+ // Own constructor properties of Json-1.0.Json.Builder
719
+
720
+ /**
721
+ * Whether the tree should be immutable when created.
722
+ *
723
+ * Making the output immutable on creation avoids the expense
724
+ * of traversing it to make it immutable later.
725
+ */
726
+ immutable?: boolean | null
727
+ }
728
+
729
+ }
730
+
731
+ interface Builder {
732
+
733
+ // Own properties of Json-1.0.Json.Builder
734
+
735
+ /**
736
+ * Whether the tree should be immutable when created.
737
+ *
738
+ * Making the output immutable on creation avoids the expense
739
+ * of traversing it to make it immutable later.
740
+ */
741
+ readonly immutable: boolean
742
+
743
+ // Owm methods of Json-1.0.Json.Builder
744
+
745
+ /**
746
+ * Adds a boolean value to the currently open object member or array.
747
+ *
748
+ * If called after [method`Json`.Builder.set_member_name], sets the given value
749
+ * as the value of the current member in the open object; otherwise, the value
750
+ * is appended to the elements of the open array.
751
+ *
752
+ * See also: [method`Json`.Builder.add_value]
753
+ * @param value the value of the member or element
754
+ * @returns the builder instance
755
+ */
756
+ add_boolean_value(value: boolean): Builder | null
757
+ /**
758
+ * Adds a floating point value to the currently open object member or array.
759
+ *
760
+ * If called after [method`Json`.Builder.set_member_name], sets the given value
761
+ * as the value of the current member in the open object; otherwise, the value
762
+ * is appended to the elements of the open array.
763
+ *
764
+ * See also: [method`Json`.Builder.add_value]
765
+ * @param value the value of the member or element
766
+ * @returns the builder instance
767
+ */
768
+ add_double_value(value: number): Builder | null
769
+ /**
770
+ * Adds an integer value to the currently open object member or array.
771
+ *
772
+ * If called after [method`Json`.Builder.set_member_name], sets the given value
773
+ * as the value of the current member in the open object; otherwise, the value
774
+ * is appended to the elements of the open array.
775
+ *
776
+ * See also: [method`Json`.Builder.add_value]
777
+ * @param value the value of the member or element
778
+ * @returns the builder instance
779
+ */
780
+ add_int_value(value: number): Builder | null
781
+ /**
782
+ * Adds a null value to the currently open object member or array.
783
+ *
784
+ * If called after [method`Json`.Builder.set_member_name], sets the given value
785
+ * as the value of the current member in the open object; otherwise, the value
786
+ * is appended to the elements of the open array.
787
+ *
788
+ * See also: [method`Json`.Builder.add_value]
789
+ * @returns the builder instance
790
+ */
791
+ add_null_value(): Builder | null
792
+ /**
793
+ * Adds a boolean value to the currently open object member or array.
794
+ *
795
+ * If called after [method`Json`.Builder.set_member_name], sets the given value
796
+ * as the value of the current member in the open object; otherwise, the value
797
+ * is appended to the elements of the open array.
798
+ *
799
+ * See also: [method`Json`.Builder.add_value]
800
+ * @param value the value of the member or element
801
+ * @returns the builder instance
802
+ */
803
+ add_string_value(value: string | null): Builder | null
804
+ /**
805
+ * Adds a value to the currently open object member or array.
806
+ *
807
+ * If called after [method`Json`.Builder.set_member_name], sets the given node
808
+ * as the value of the current member in the open object; otherwise, the node
809
+ * is appended to the elements of the open array.
810
+ *
811
+ * The builder will take ownership of the node.
812
+ * @param node the value of the member or element
813
+ * @returns the builder instance
814
+ */
815
+ add_value(node: Node): Builder | null
816
+ /**
817
+ * Opens an array inside the given builder.
818
+ *
819
+ * You can add a new element to the array by using [method`Json`.Builder.add_value].
820
+ *
821
+ * Once you added all elements to the array, you must call
822
+ * [method`Json`.Builder.end_array] to close the array.
823
+ * @returns the builder instance
824
+ */
825
+ begin_array(): Builder | null
826
+ /**
827
+ * Opens an object inside the given builder.
828
+ *
829
+ * You can add a new member to the object by using [method`Json`.Builder.set_member_name],
830
+ * followed by [method`Json`.Builder.add_value].
831
+ *
832
+ * Once you added all members to the object, you must call [method`Json`.Builder.end_object]
833
+ * to close the object.
834
+ *
835
+ * If the builder is in an inconsistent state, this function will return `NULL`.
836
+ * @returns the builder instance
837
+ */
838
+ begin_object(): Builder | null
839
+ /**
840
+ * Closes the array inside the given builder that was opened by the most
841
+ * recent call to [method`Json`.Builder.begin_array].
842
+ *
843
+ * This function cannot be called after [method`Json`.Builder.set_member_name].
844
+ * @returns the builder instance
845
+ */
846
+ end_array(): Builder | null
847
+ /**
848
+ * Closes the object inside the given builder that was opened by the most
849
+ * recent call to [method`Json`.Builder.begin_object].
850
+ *
851
+ * This function cannot be called after [method`Json`.Builder.set_member_name].
852
+ * @returns the builder instance
853
+ */
854
+ end_object(): Builder | null
855
+ /**
856
+ * Returns the root of the currently constructed tree.
857
+ *
858
+ * if the build is incomplete (ie: if there are any opened objects, or any
859
+ * open object members and array elements) then this function will return
860
+ * `NULL`.
861
+ * @returns the root node
862
+ */
863
+ get_root(): Node | null
864
+ /**
865
+ * Resets the state of the builder back to its initial state.
866
+ */
867
+ reset(): void
868
+ /**
869
+ * Sets the name of the member in an object.
870
+ *
871
+ * This function must be followed by of these functions:
872
+ *
873
+ * - [method`Json`.Builder.add_value], to add a scalar value to the member
874
+ * - [method`Json`.Builder.begin_object], to add an object to the member
875
+ * - [method`Json`.Builder.begin_array], to add an array to the member
876
+ *
877
+ * This function can only be called within an open object.
878
+ * @param member_name the name of the member
879
+ * @returns the builder instance
880
+ */
881
+ set_member_name(member_name: string | null): Builder | null
882
+
883
+ // Class property signals of Json-1.0.Json.Builder
884
+
885
+ connect(sigName: "notify::immutable", callback: (($obj: Builder, pspec: GObject.ParamSpec) => void)): number
886
+ connect_after(sigName: "notify::immutable", callback: (($obj: Builder, pspec: GObject.ParamSpec) => void)): number
887
+ emit(sigName: "notify::immutable", ...args: any[]): void
888
+ connect(sigName: string, callback: (...args: any[]) => void): number
889
+ connect_after(sigName: string, callback: (...args: any[]) => void): number
890
+ emit(sigName: string, ...args: any[]): void
891
+ disconnect(id: number): void
892
+ }
893
+
894
+ /**
895
+ * `JsonBuilder` provides an object for generating a JSON tree.
896
+ *
897
+ * The root of the JSON tree can be either a [struct`Json`.Object] or a [struct`Json`.Array].
898
+ * Thus the first call must necessarily be either
899
+ * [method`Json`.Builder.begin_object] or [method`Json`.Builder.begin_array].
900
+ *
901
+ * For convenience to language bindings, most `JsonBuilder` method return the
902
+ * instance, making it easy to chain function calls.
903
+ *
904
+ * ## Using `JsonBuilder`
905
+ *
906
+ * ```c
907
+ * g_autoptr(JsonBuilder) builder = json_builder_new ();
908
+ *
909
+ * json_builder_begin_object (builder);
910
+ *
911
+ * json_builder_set_member_name (builder, "url");
912
+ * json_builder_add_string_value (builder, "http://www.gnome.org/img/flash/two-thirty.png");
913
+ *
914
+ * json_builder_set_member_name (builder, "size");
915
+ * json_builder_begin_array (builder);
916
+ * json_builder_add_int_value (builder, 652);
917
+ * json_builder_add_int_value (builder, 242);
918
+ * json_builder_end_array (builder);
919
+ *
920
+ * json_builder_end_object (builder);
921
+ *
922
+ * g_autoptr(JsonNode) root = json_builder_get_root (builder);
923
+ *
924
+ * g_autoptr(JsonGenerator) gen = json_generator_new ();
925
+ * json_generator_set_root (gen, root);
926
+ * g_autofree char *str = json_generator_to_data (gen, NULL);
927
+ *
928
+ * // str now contains the following JSON data
929
+ * // { "url" : "http://www.gnome.org/img/flash/two-thirty.png", "size" : [ 652, 242 ] }
930
+ * ```
931
+ * @class
932
+ */
933
+ class Builder extends GObject.Object {
934
+
935
+ // Own properties of Json-1.0.Json.Builder
936
+
937
+ static name: string
938
+ static $gtype: GObject.GType<Builder>
939
+
940
+ // Constructors of Json-1.0.Json.Builder
941
+
942
+ constructor(config?: Builder.ConstructorProperties)
943
+ /**
944
+ * Creates a new `JsonBuilder`.
945
+ *
946
+ * You can use this object to generate a JSON tree and obtain the root node.
947
+ * @constructor
948
+ * @returns the newly created builder instance
949
+ */
950
+ constructor()
951
+ /**
952
+ * Creates a new `JsonBuilder`.
953
+ *
954
+ * You can use this object to generate a JSON tree and obtain the root node.
955
+ * @constructor
956
+ * @returns the newly created builder instance
957
+ */
958
+ static new(): Builder
959
+ /**
960
+ * Creates a new, immutable `JsonBuilder` instance.
961
+ *
962
+ * It is equivalent to setting the [property`Json`.Builder:immutable] property
963
+ * set to `TRUE` at construction time.
964
+ * @constructor
965
+ * @returns the newly create builder instance
966
+ */
967
+ static new_immutable(): Builder
968
+ _init(config?: Builder.ConstructorProperties): void
969
+ }
970
+
971
+ module Generator {
972
+
973
+ // Constructor properties interface
974
+
975
+ interface ConstructorProperties extends GObject.Object.ConstructorProperties {
976
+
977
+ // Own constructor properties of Json-1.0.Json.Generator
978
+
979
+ /**
980
+ * Number of spaces to be used to indent when pretty printing.
981
+ */
982
+ indent?: number | null
983
+ /**
984
+ * The character that should be used when indenting in pretty print.
985
+ */
986
+ indent_char?: number | null
987
+ /**
988
+ * Whether the output should be "pretty-printed", with indentation and
989
+ * newlines.
990
+ *
991
+ * The indentation level can be controlled by using the
992
+ * [property`Json`.Generator:indent] property.
993
+ */
994
+ pretty?: boolean | null
995
+ /**
996
+ * The root node to be used when constructing a JSON data
997
+ * stream.
998
+ */
999
+ root?: Node | null
1000
+ }
1001
+
1002
+ }
1003
+
1004
+ interface Generator {
1005
+
1006
+ // Own properties of Json-1.0.Json.Generator
1007
+
1008
+ /**
1009
+ * Number of spaces to be used to indent when pretty printing.
1010
+ */
1011
+ indent: number
1012
+ /**
1013
+ * The character that should be used when indenting in pretty print.
1014
+ */
1015
+ indent_char: number
1016
+ /**
1017
+ * Whether the output should be "pretty-printed", with indentation and
1018
+ * newlines.
1019
+ *
1020
+ * The indentation level can be controlled by using the
1021
+ * [property`Json`.Generator:indent] property.
1022
+ */
1023
+ pretty: boolean
1024
+ /**
1025
+ * The root node to be used when constructing a JSON data
1026
+ * stream.
1027
+ */
1028
+ root: Node
1029
+
1030
+ // Owm methods of Json-1.0.Json.Generator
1031
+
1032
+ /**
1033
+ * Retrieves the value set using [method`Json`.Generator.set_indent].
1034
+ * @returns the number of repetitions per indentation level
1035
+ */
1036
+ get_indent(): number
1037
+ /**
1038
+ * Retrieves the value set using [method`Json`.Generator.set_indent_char].
1039
+ * @returns the character to be used when indenting
1040
+ */
1041
+ get_indent_char(): string
1042
+ /**
1043
+ * Retrieves the value set using [method`Json`.Generator.set_pretty].
1044
+ * @returns `TRUE` if the generated JSON should be pretty-printed, and `FALSE` otherwise
1045
+ */
1046
+ get_pretty(): boolean
1047
+ /**
1048
+ * Retrieves a pointer to the root node set using
1049
+ * [method`Json`.Generator.set_root].
1050
+ * @returns the root node
1051
+ */
1052
+ get_root(): Node | null
1053
+ /**
1054
+ * Sets the number of repetitions for each indentation level.
1055
+ * @param indent_level the number of repetitions of the indentation character that should be applied when pretty printing
1056
+ */
1057
+ set_indent(indent_level: number): void
1058
+ /**
1059
+ * Sets the character to be used when indenting.
1060
+ * @param indent_char a Unicode character to be used when indenting
1061
+ */
1062
+ set_indent_char(indent_char: string): void
1063
+ /**
1064
+ * Sets whether the generated JSON should be pretty printed.
1065
+ *
1066
+ * Pretty printing will use indentation character specified in the
1067
+ * [property`Json`.Generator:indent-char] property and the spacing
1068
+ * specified in the [property`Json`.Generator:indent] property.
1069
+ * @param is_pretty whether the generated string should be pretty printed
1070
+ */
1071
+ set_pretty(is_pretty: boolean): void
1072
+ /**
1073
+ * Sets the root of the JSON data stream to be serialized by
1074
+ * the given generator.
1075
+ *
1076
+ * The passed `node` is copied by the generator object, so it can be
1077
+ * safely freed after calling this function.
1078
+ * @param node the root node
1079
+ */
1080
+ set_root(node: Node): void
1081
+ /**
1082
+ * Generates a JSON data stream from `generator` and returns it as a
1083
+ * buffer.
1084
+ * @returns a newly allocated string holding a JSON data stream
1085
+ */
1086
+ to_data(): [ /* returnType */ string | null, /* length */ number ]
1087
+ /**
1088
+ * Creates a JSON data stream and puts it inside `filename`, overwriting
1089
+ * the file's current contents.
1090
+ *
1091
+ * This operation is atomic, in the sense that the data is written to a
1092
+ * temporary file which is then renamed to the given `filename`.
1093
+ * @param filename the path to the target file
1094
+ * @returns %TRUE if saving was successful.
1095
+ */
1096
+ to_file(filename: string): boolean
1097
+ /**
1098
+ * Generates a JSON data stream and appends it to the string buffer.
1099
+ * @param string a string buffer
1100
+ * @returns the passed string, updated with the generated JSON data
1101
+ */
1102
+ to_gstring(string: GLib.String): GLib.String
1103
+ /**
1104
+ * Outputs JSON data and writes it (synchronously) to the given stream.
1105
+ * @param stream the output stream used to write the JSON data
1106
+ * @param cancellable a `GCancellable`
1107
+ * @returns whether the write operation was successful
1108
+ */
1109
+ to_stream(stream: Gio.OutputStream, cancellable: Gio.Cancellable | null): boolean
1110
+
1111
+ // Class property signals of Json-1.0.Json.Generator
1112
+
1113
+ connect(sigName: "notify::indent", callback: (($obj: Generator, pspec: GObject.ParamSpec) => void)): number
1114
+ connect_after(sigName: "notify::indent", callback: (($obj: Generator, pspec: GObject.ParamSpec) => void)): number
1115
+ emit(sigName: "notify::indent", ...args: any[]): void
1116
+ connect(sigName: "notify::indent-char", callback: (($obj: Generator, pspec: GObject.ParamSpec) => void)): number
1117
+ connect_after(sigName: "notify::indent-char", callback: (($obj: Generator, pspec: GObject.ParamSpec) => void)): number
1118
+ emit(sigName: "notify::indent-char", ...args: any[]): void
1119
+ connect(sigName: "notify::pretty", callback: (($obj: Generator, pspec: GObject.ParamSpec) => void)): number
1120
+ connect_after(sigName: "notify::pretty", callback: (($obj: Generator, pspec: GObject.ParamSpec) => void)): number
1121
+ emit(sigName: "notify::pretty", ...args: any[]): void
1122
+ connect(sigName: "notify::root", callback: (($obj: Generator, pspec: GObject.ParamSpec) => void)): number
1123
+ connect_after(sigName: "notify::root", callback: (($obj: Generator, pspec: GObject.ParamSpec) => void)): number
1124
+ emit(sigName: "notify::root", ...args: any[]): void
1125
+ connect(sigName: string, callback: (...args: any[]) => void): number
1126
+ connect_after(sigName: string, callback: (...args: any[]) => void): number
1127
+ emit(sigName: string, ...args: any[]): void
1128
+ disconnect(id: number): void
1129
+ }
1130
+
1131
+ /**
1132
+ * `JsonGenerator` provides an object for generating a JSON data stream
1133
+ * from a tree of [struct`Json`.Node] instances, and put it into a buffer
1134
+ * or a file.
1135
+ * @class
1136
+ */
1137
+ class Generator extends GObject.Object {
1138
+
1139
+ // Own properties of Json-1.0.Json.Generator
1140
+
1141
+ static name: string
1142
+ static $gtype: GObject.GType<Generator>
1143
+
1144
+ // Constructors of Json-1.0.Json.Generator
1145
+
1146
+ constructor(config?: Generator.ConstructorProperties)
1147
+ /**
1148
+ * Creates a new `JsonGenerator`.
1149
+ *
1150
+ * You can use this object to generate a JSON data stream starting from a
1151
+ * data object model composed by [struct`Json`.Node]s.
1152
+ * @constructor
1153
+ * @returns the newly created generator instance
1154
+ */
1155
+ constructor()
1156
+ /**
1157
+ * Creates a new `JsonGenerator`.
1158
+ *
1159
+ * You can use this object to generate a JSON data stream starting from a
1160
+ * data object model composed by [struct`Json`.Node]s.
1161
+ * @constructor
1162
+ * @returns the newly created generator instance
1163
+ */
1164
+ static new(): Generator
1165
+ _init(config?: Generator.ConstructorProperties): void
1166
+ }
1167
+
1168
+ module Parser {
1169
+
1170
+ // Signal callback interfaces
1171
+
1172
+ /**
1173
+ * Signal callback interface for `array-element`
1174
+ */
1175
+ interface ArrayElementSignalCallback {
1176
+ ($obj: Parser, array: Array, index_: number): void
1177
+ }
1178
+
1179
+ /**
1180
+ * Signal callback interface for `array-end`
1181
+ */
1182
+ interface ArrayEndSignalCallback {
1183
+ ($obj: Parser, array: Array): void
1184
+ }
1185
+
1186
+ /**
1187
+ * Signal callback interface for `array-start`
1188
+ */
1189
+ interface ArrayStartSignalCallback {
1190
+ ($obj: Parser): void
1191
+ }
1192
+
1193
+ /**
1194
+ * Signal callback interface for `error`
1195
+ */
1196
+ interface ErrorSignalCallback {
1197
+ ($obj: Parser, error: any | null): void
1198
+ }
1199
+
1200
+ /**
1201
+ * Signal callback interface for `object-end`
1202
+ */
1203
+ interface ObjectEndSignalCallback {
1204
+ ($obj: Parser, object: Object): void
1205
+ }
1206
+
1207
+ /**
1208
+ * Signal callback interface for `object-member`
1209
+ */
1210
+ interface ObjectMemberSignalCallback {
1211
+ ($obj: Parser, object: Object, member_name: string | null): void
1212
+ }
1213
+
1214
+ /**
1215
+ * Signal callback interface for `object-start`
1216
+ */
1217
+ interface ObjectStartSignalCallback {
1218
+ ($obj: Parser): void
1219
+ }
1220
+
1221
+ /**
1222
+ * Signal callback interface for `parse-end`
1223
+ */
1224
+ interface ParseEndSignalCallback {
1225
+ ($obj: Parser): void
1226
+ }
1227
+
1228
+ /**
1229
+ * Signal callback interface for `parse-start`
1230
+ */
1231
+ interface ParseStartSignalCallback {
1232
+ ($obj: Parser): void
1233
+ }
1234
+
1235
+
1236
+ // Constructor properties interface
1237
+
1238
+ interface ConstructorProperties extends GObject.Object.ConstructorProperties {
1239
+
1240
+ // Own constructor properties of Json-1.0.Json.Parser
1241
+
1242
+ /**
1243
+ * Whether the tree built by the parser should be immutable
1244
+ * when created.
1245
+ *
1246
+ * Making the output immutable on creation avoids the expense
1247
+ * of traversing it to make it immutable later.
1248
+ */
1249
+ immutable?: boolean | null
1250
+ }
1251
+
1252
+ }
1253
+
1254
+ interface Parser {
1255
+
1256
+ // Own properties of Json-1.0.Json.Parser
1257
+
1258
+ /**
1259
+ * Whether the tree built by the parser should be immutable
1260
+ * when created.
1261
+ *
1262
+ * Making the output immutable on creation avoids the expense
1263
+ * of traversing it to make it immutable later.
1264
+ */
1265
+ readonly immutable: boolean
1266
+
1267
+ // Owm methods of Json-1.0.Json.Parser
1268
+
1269
+ /**
1270
+ * Retrieves the line currently parsed, starting from 1.
1271
+ *
1272
+ * This function has defined behaviour only while parsing; calling this
1273
+ * function from outside the signal handlers emitted by the parser will
1274
+ * yield 0.
1275
+ * @returns the currently parsed line, or 0.
1276
+ */
1277
+ get_current_line(): number
1278
+ /**
1279
+ * Retrieves the current position inside the current line, starting
1280
+ * from 0.
1281
+ *
1282
+ * This function has defined behaviour only while parsing; calling this
1283
+ * function from outside the signal handlers emitted by the parser will
1284
+ * yield 0.
1285
+ * @returns the position in the current line, or 0.
1286
+ */
1287
+ get_current_pos(): number
1288
+ /**
1289
+ * Retrieves the top level node from the parsed JSON stream.
1290
+ *
1291
+ * If the parser input was an empty string, or if parsing failed, the root
1292
+ * will be `NULL`. It will also be `NULL` if it has been stolen using
1293
+ * [method`Json`.Parser.steal_root].
1294
+ * @returns the root node.
1295
+ */
1296
+ get_root(): Node | null
1297
+ /**
1298
+ * A JSON data stream might sometimes contain an assignment, like:
1299
+ *
1300
+ * ```
1301
+ * var _json_data = { "member_name" : [ ...
1302
+ * ```
1303
+ *
1304
+ * even though it would technically constitute a violation of the RFC.
1305
+ *
1306
+ * `JsonParser` will ignore the left hand identifier and parse the right
1307
+ * hand value of the assignment. `JsonParser` will record, though, the
1308
+ * existence of the assignment in the data stream and the variable name
1309
+ * used.
1310
+ * @returns `TRUE` if there was an assignment, and `FALSE` otherwise
1311
+ */
1312
+ has_assignment(): [ /* returnType */ boolean, /* variable_name */ string | null ]
1313
+ /**
1314
+ * Loads a JSON stream from a buffer and parses it.
1315
+ *
1316
+ * You can call this function multiple times with the same parser, but the
1317
+ * contents of the parser will be destroyed each time.
1318
+ * @param data the buffer to parse
1319
+ * @param length the length of the buffer, or -1 if it is `NUL` terminated
1320
+ * @returns `TRUE` if the buffer was succesfully parsed
1321
+ */
1322
+ load_from_data(data: string | null, length: number): boolean
1323
+ /**
1324
+ * Loads a JSON stream from the content of `filename` and parses it.
1325
+ *
1326
+ * If the file is large or shared between processes,
1327
+ * [method`Json`.Parser.load_from_mapped_file] may be a more efficient
1328
+ * way to load it.
1329
+ *
1330
+ * See also: [method`Json`.Parser.load_from_data]
1331
+ * @param filename the path for the file to parse
1332
+ * @returns `TRUE` if the file was successfully loaded and parsed.
1333
+ */
1334
+ load_from_file(filename: string): boolean
1335
+ /**
1336
+ * Loads a JSON stream from the content of `filename` and parses it.
1337
+ *
1338
+ * Unlike [method`Json`.Parser.load_from_file], `filename` will be memory
1339
+ * mapped as read-only and parsed. `filename` will be unmapped before this
1340
+ * function returns.
1341
+ *
1342
+ * If mapping or reading the file fails, a `G_FILE_ERROR` will be returned.
1343
+ * @param filename the path for the file to parse
1344
+ * @returns `TRUE` if the file was successfully loaded and parsed.
1345
+ */
1346
+ load_from_mapped_file(filename: string): boolean
1347
+ /**
1348
+ * Loads the contents of an input stream and parses them.
1349
+ *
1350
+ * If `cancellable` is not `NULL`, then the operation can be cancelled by
1351
+ * triggering the cancellable object from another thread. If the
1352
+ * operation was cancelled, `G_IO_ERROR_CANCELLED` will be set
1353
+ * on the given `error`.
1354
+ * @param stream the input stream with the JSON data
1355
+ * @param cancellable a #GCancellable
1356
+ * @returns `TRUE` if the data stream was successfully read and parsed, and `FALSE` otherwise
1357
+ */
1358
+ load_from_stream(stream: Gio.InputStream, cancellable: Gio.Cancellable | null): boolean
1359
+ /**
1360
+ * Asynchronously reads the contents of a stream.
1361
+ *
1362
+ * For more details, see [method`Json`.Parser.load_from_stream], which is the
1363
+ * synchronous version of this call.
1364
+ *
1365
+ * When the operation is finished, `callback` will be called. You should
1366
+ * then call [method`Json`.Parser.load_from_stream_finish] to get the result
1367
+ * of the operation.
1368
+ * @param stream the input stream with the JSON data
1369
+ * @param cancellable a #GCancellable
1370
+ * @param callback the function to call when the request is satisfied
1371
+ */
1372
+ load_from_stream_async(stream: Gio.InputStream, cancellable: Gio.Cancellable | null, callback: Gio.AsyncReadyCallback<this> | null): void
1373
+ /**
1374
+ * Finishes an asynchronous stream loading started with
1375
+ * [method`Json`.Parser.load_from_stream_async].
1376
+ * @param result the result of the asynchronous operation
1377
+ * @returns `TRUE` if the content of the stream was successfully retrieved and parsed, and `FALSE` otherwise
1378
+ */
1379
+ load_from_stream_finish(result: Gio.AsyncResult): boolean
1380
+ /**
1381
+ * Steals the top level node from the parsed JSON stream.
1382
+ *
1383
+ * This will be `NULL` in the same situations as [method`Json`.Parser.get_root]
1384
+ * return `NULL`.
1385
+ * @returns the root node
1386
+ */
1387
+ steal_root(): Node | null
1388
+
1389
+ // Own virtual methods of Json-1.0.Json.Parser
1390
+
1391
+ vfunc_array_element(array: Array, index_: number): void
1392
+ vfunc_array_end(array: Array): void
1393
+ vfunc_array_start(): void
1394
+ vfunc_error(error: GLib.Error): void
1395
+ vfunc_object_end(object: Object): void
1396
+ vfunc_object_member(object: Object, member_name: string | null): void
1397
+ vfunc_object_start(): void
1398
+ vfunc_parse_end(): void
1399
+ vfunc_parse_start(): void
1400
+
1401
+ // Own signals of Json-1.0.Json.Parser
1402
+
1403
+ connect(sigName: "array-element", callback: Parser.ArrayElementSignalCallback): number
1404
+ connect_after(sigName: "array-element", callback: Parser.ArrayElementSignalCallback): number
1405
+ emit(sigName: "array-element", array: Array, index_: number, ...args: any[]): void
1406
+ connect(sigName: "array-end", callback: Parser.ArrayEndSignalCallback): number
1407
+ connect_after(sigName: "array-end", callback: Parser.ArrayEndSignalCallback): number
1408
+ emit(sigName: "array-end", array: Array, ...args: any[]): void
1409
+ connect(sigName: "array-start", callback: Parser.ArrayStartSignalCallback): number
1410
+ connect_after(sigName: "array-start", callback: Parser.ArrayStartSignalCallback): number
1411
+ emit(sigName: "array-start", ...args: any[]): void
1412
+ connect(sigName: "error", callback: Parser.ErrorSignalCallback): number
1413
+ connect_after(sigName: "error", callback: Parser.ErrorSignalCallback): number
1414
+ emit(sigName: "error", error: any | null, ...args: any[]): void
1415
+ connect(sigName: "object-end", callback: Parser.ObjectEndSignalCallback): number
1416
+ connect_after(sigName: "object-end", callback: Parser.ObjectEndSignalCallback): number
1417
+ emit(sigName: "object-end", object: Object, ...args: any[]): void
1418
+ connect(sigName: "object-member", callback: Parser.ObjectMemberSignalCallback): number
1419
+ connect_after(sigName: "object-member", callback: Parser.ObjectMemberSignalCallback): number
1420
+ emit(sigName: "object-member", object: Object, member_name: string | null, ...args: any[]): void
1421
+ connect(sigName: "object-start", callback: Parser.ObjectStartSignalCallback): number
1422
+ connect_after(sigName: "object-start", callback: Parser.ObjectStartSignalCallback): number
1423
+ emit(sigName: "object-start", ...args: any[]): void
1424
+ connect(sigName: "parse-end", callback: Parser.ParseEndSignalCallback): number
1425
+ connect_after(sigName: "parse-end", callback: Parser.ParseEndSignalCallback): number
1426
+ emit(sigName: "parse-end", ...args: any[]): void
1427
+ connect(sigName: "parse-start", callback: Parser.ParseStartSignalCallback): number
1428
+ connect_after(sigName: "parse-start", callback: Parser.ParseStartSignalCallback): number
1429
+ emit(sigName: "parse-start", ...args: any[]): void
1430
+
1431
+ // Class property signals of Json-1.0.Json.Parser
1432
+
1433
+ connect(sigName: "notify::immutable", callback: (($obj: Parser, pspec: GObject.ParamSpec) => void)): number
1434
+ connect_after(sigName: "notify::immutable", callback: (($obj: Parser, pspec: GObject.ParamSpec) => void)): number
1435
+ emit(sigName: "notify::immutable", ...args: any[]): void
1436
+ connect(sigName: string, callback: (...args: any[]) => void): number
1437
+ connect_after(sigName: string, callback: (...args: any[]) => void): number
1438
+ emit(sigName: string, ...args: any[]): void
1439
+ disconnect(id: number): void
1440
+ }
1441
+
1442
+ /**
1443
+ * `JsonParser` provides an object for parsing a JSON data stream, either
1444
+ * inside a file or inside a static buffer.
1445
+ *
1446
+ * ## Using `JsonParser`
1447
+ *
1448
+ * The `JsonParser` API is fairly simple:
1449
+ *
1450
+ * ```c
1451
+ * gboolean
1452
+ * parse_json (const char *filename)
1453
+ * {
1454
+ * g_autoptr(JsonParser) parser = json_parser_new ();
1455
+ * g_autoptr(GError) error = NULL
1456
+ *
1457
+ * json_parser_load_from_file (parser, filename, &error);
1458
+ * if (error != NULL)
1459
+ * {
1460
+ * g_critical ("Unable to parse '%s': %s", filename, error->message);
1461
+ * return FALSE;
1462
+ * }
1463
+ *
1464
+ * g_autoptr(JsonNode) root = json_parser_get_root (parser);
1465
+ *
1466
+ * // manipulate the object tree from the root node
1467
+ *
1468
+ * return TRUE
1469
+ * }
1470
+ * ```
1471
+ *
1472
+ * By default, the entire process of loading the data and parsing it is
1473
+ * synchronous; the [method`Json`.Parser.load_from_stream_async()] API will
1474
+ * load the data asynchronously, but parse it in the main context as the
1475
+ * signals of the parser must be emitted in the same thread. If you do
1476
+ * not use signals, and you wish to also parse the JSON data without blocking,
1477
+ * you should use a `GTask` and the synchronous `JsonParser` API inside the
1478
+ * task itself.
1479
+ * @class
1480
+ */
1481
+ class Parser extends GObject.Object {
1482
+
1483
+ // Own properties of Json-1.0.Json.Parser
1484
+
1485
+ static name: string
1486
+ static $gtype: GObject.GType<Parser>
1487
+
1488
+ // Constructors of Json-1.0.Json.Parser
1489
+
1490
+ constructor(config?: Parser.ConstructorProperties)
1491
+ /**
1492
+ * Creates a new JSON parser.
1493
+ *
1494
+ * You can use the `JsonParser` to load a JSON stream from either a file or a
1495
+ * buffer and then walk the hierarchy using the data types API.
1496
+ * @constructor
1497
+ * @returns the newly created parser
1498
+ */
1499
+ constructor()
1500
+ /**
1501
+ * Creates a new JSON parser.
1502
+ *
1503
+ * You can use the `JsonParser` to load a JSON stream from either a file or a
1504
+ * buffer and then walk the hierarchy using the data types API.
1505
+ * @constructor
1506
+ * @returns the newly created parser
1507
+ */
1508
+ static new(): Parser
1509
+ /**
1510
+ * Creates a new parser instance with its [property`Json`.Parser:immutable]
1511
+ * property set to `TRUE` to create immutable output trees.
1512
+ * @constructor
1513
+ * @returns the newly created parser
1514
+ */
1515
+ static new_immutable(): Parser
1516
+ _init(config?: Parser.ConstructorProperties): void
1517
+ }
1518
+
1519
+ module Path {
1520
+
1521
+ // Constructor properties interface
1522
+
1523
+ interface ConstructorProperties extends GObject.Object.ConstructorProperties {
1524
+ }
1525
+
1526
+ }
1527
+
1528
+ interface Path {
1529
+
1530
+ // Owm methods of Json-1.0.Json.Path
1531
+
1532
+ /**
1533
+ * Validates and decomposes the given expression.
1534
+ *
1535
+ * A JSONPath expression must be compiled before calling
1536
+ * [method`Json`.Path.match].
1537
+ * @param expression a JSONPath expression
1538
+ * @returns `TRUE` if the compilation was successful, and `FALSE` otherwise
1539
+ */
1540
+ compile(expression: string | null): boolean
1541
+ /**
1542
+ * Matches the JSON tree pointed by `root` using the expression compiled
1543
+ * into the `JsonPath`.
1544
+ *
1545
+ * The nodes matching the expression will be copied into an array.
1546
+ * @param root the root node of the JSON data to match
1547
+ * @returns a newly-created node of type `JSON_NODE_ARRAY` containing the array of matching nodes
1548
+ */
1549
+ match(root: Node): Node
1550
+
1551
+ // Class property signals of Json-1.0.Json.Path
1552
+
1553
+ connect(sigName: string, callback: (...args: any[]) => void): number
1554
+ connect_after(sigName: string, callback: (...args: any[]) => void): number
1555
+ emit(sigName: string, ...args: any[]): void
1556
+ disconnect(id: number): void
1557
+ }
1558
+
1559
+ /**
1560
+ * `JsonPath` is a simple class implementing the JSONPath syntax for extracting
1561
+ * data out of a JSON tree.
1562
+ *
1563
+ * While the semantics of the JSONPath expressions are heavily borrowed by the
1564
+ * XPath specification for XML, the syntax follows the ECMAScript origins of
1565
+ * JSON.
1566
+ *
1567
+ * Once a `JsonPath` instance has been created, it has to compile a JSONPath
1568
+ * expression using [method`Json`.Path.compile] before being able to match it to
1569
+ * a JSON tree; the same `JsonPath` instance can be used to match multiple JSON
1570
+ * trees. It it also possible to compile a new JSONPath expression using the
1571
+ * same `JsonPath` instance; the previous expression will be discarded only if
1572
+ * the compilation of the new expression is successful.
1573
+ *
1574
+ * The simple convenience function [func`Json`.Path.query] can be used for
1575
+ * one-off matching.
1576
+ *
1577
+ * ## Syntax of the JSONPath expressions
1578
+ *
1579
+ * A JSONPath expression is composed by path indices and operators.
1580
+ * Each path index can either be a member name or an element index inside
1581
+ * a JSON tree. A JSONPath expression must start with the `$` operator; each
1582
+ * path index is separated using either the dot notation or the bracket
1583
+ * notation, e.g.:
1584
+ *
1585
+ * ```
1586
+ * // dot notation
1587
+ * $.store.book[0].title
1588
+ *
1589
+ * // bracket notation
1590
+ * $['store']['book'][0]['title']
1591
+ * ```
1592
+ *
1593
+ * The available operators are:
1594
+ *
1595
+ * * The `$` character represents the root node of the JSON tree, and
1596
+ * matches the entire document.
1597
+ *
1598
+ * * Child nodes can either be matched using `.` or `[]`. For instance,
1599
+ * both `$.store.book` and `$['store']['book']` match the contents of
1600
+ * the book member of the store object.
1601
+ *
1602
+ * * Child nodes can be reached without specifying the whole tree structure
1603
+ * through the recursive descent operator, or `..`. For instance,
1604
+ * `$..author` matches all author member in every object.
1605
+ *
1606
+ * * Child nodes can grouped through the wildcard operator, or `*`. For
1607
+ * instance, `$.store.book[*].author` matches all author members of any
1608
+ * object element contained in the book array of the store object.
1609
+ *
1610
+ * * Element nodes can be accessed using their index (starting from zero)
1611
+ * in the subscript operator `[]`. For instance, `$.store.book[0]` matches
1612
+ * the first element of the book array of the store object.
1613
+ *
1614
+ * * Subsets of element nodes can be accessed using the set notation
1615
+ * operator `[i,j,...]`. For instance, `$.store.book[0,2]` matches the
1616
+ * elements 0 and 2 (the first and third) of the book array of the store
1617
+ * object.
1618
+ *
1619
+ * * Slices of element nodes can be accessed using the slice notation
1620
+ * operation `[start:end:step]`. If start is omitted, the starting index
1621
+ * of the slice is implied to be zero; if end is omitted, the ending index
1622
+ * of the slice is implied to be the length of the array; if step is
1623
+ * omitted, the step of the slice is implied to be 1. For instance,
1624
+ * `$.store.book[:2]` matches the first two elements of the book array
1625
+ * of the store object.
1626
+ *
1627
+ * More information about JSONPath is available on Stefan Gössner's
1628
+ * [JSONPath website](http://goessner.net/articles/JsonPath/).
1629
+ *
1630
+ * ## Example of JSONPath matches
1631
+ *
1632
+ * The following example shows some of the results of using `JsonPath`
1633
+ * on a JSON tree. We use the following JSON description of a bookstore:
1634
+ *
1635
+ * ```json
1636
+ * { "store": {
1637
+ * "book": [
1638
+ * { "category": "reference", "author": "Nigel Rees",
1639
+ * "title": "Sayings of the Century", "price": "8.95" },
1640
+ * { "category": "fiction", "author": "Evelyn Waugh",
1641
+ * "title": "Sword of Honour", "price": "12.99" },
1642
+ * { "category": "fiction", "author": "Herman Melville",
1643
+ * "title": "Moby Dick", "isbn": "0-553-21311-3",
1644
+ * "price": "8.99" },
1645
+ * { "category": "fiction", "author": "J. R. R. Tolkien",
1646
+ * "title": "The Lord of the Rings", "isbn": "0-395-19395-8",
1647
+ * "price": "22.99" }
1648
+ * ],
1649
+ * "bicycle": { "color": "red", "price": "19.95" }
1650
+ * }
1651
+ * }
1652
+ * ```
1653
+ *
1654
+ * We can parse the JSON using [class`Json`.Parser]:
1655
+ *
1656
+ * ```c
1657
+ * JsonParser *parser = json_parser_new ();
1658
+ * json_parser_load_from_data (parser, json_data, -1, NULL);
1659
+ * ```
1660
+ *
1661
+ * If we run the following code:
1662
+ *
1663
+ * ```c
1664
+ * JsonNode *result;
1665
+ * JsonPath *path = json_path_new ();
1666
+ * json_path_compile (path, "$.store..author", NULL);
1667
+ * result = json_path_match (path, json_parser_get_root (parser));
1668
+ * ```
1669
+ *
1670
+ * The `result` node will contain an array with all values of the
1671
+ * author member of the objects in the JSON tree. If we use a
1672
+ * [class`Json`.Generator] to convert the `result` node to a string
1673
+ * and print it:
1674
+ *
1675
+ * ```c
1676
+ * JsonGenerator *generator = json_generator_new ();
1677
+ * json_generator_set_root (generator, result);
1678
+ * char *str = json_generator_to_data (generator, NULL);
1679
+ * g_print ("Results: %s\n", str);
1680
+ * ```
1681
+ *
1682
+ * The output will be:
1683
+ *
1684
+ * ```json
1685
+ * ["Nigel Rees","Evelyn Waugh","Herman Melville","J. R. R. Tolkien"]
1686
+ * ```
1687
+ * @class
1688
+ */
1689
+ class Path extends GObject.Object {
1690
+
1691
+ // Own properties of Json-1.0.Json.Path
1692
+
1693
+ static name: string
1694
+ static $gtype: GObject.GType<Path>
1695
+
1696
+ // Constructors of Json-1.0.Json.Path
1697
+
1698
+ constructor(config?: Path.ConstructorProperties)
1699
+ /**
1700
+ * Creates a new `JsonPath` instance.
1701
+ *
1702
+ * Once created, the `JsonPath` object should be used with
1703
+ * [method`Json`.Path.compile] and [method`Json`.Path.match].
1704
+ * @constructor
1705
+ * @returns the newly created path
1706
+ */
1707
+ constructor()
1708
+ /**
1709
+ * Creates a new `JsonPath` instance.
1710
+ *
1711
+ * Once created, the `JsonPath` object should be used with
1712
+ * [method`Json`.Path.compile] and [method`Json`.Path.match].
1713
+ * @constructor
1714
+ * @returns the newly created path
1715
+ */
1716
+ static new(): Path
1717
+ _init(config?: Path.ConstructorProperties): void
1718
+ /**
1719
+ * Queries a JSON tree using a JSONPath expression.
1720
+ *
1721
+ * This function is a simple wrapper around [ctor`Json`.Path.new],
1722
+ * [method`Json`.Path.compile], and [method`Json`.Path.match]. It implicitly
1723
+ * creates a `JsonPath` instance, compiles the given expression and matches
1724
+ * it against the JSON tree pointed by `root`.
1725
+ * @param expression a JSONPath expression
1726
+ * @param root the root of a JSON tree
1727
+ * @returns a newly-created node of type `JSON_NODE_ARRAY` containing the array of matching nodes
1728
+ */
1729
+ static query(expression: string | null, root: Node): Node
1730
+ }
1731
+
1732
+ module Reader {
1733
+
1734
+ // Constructor properties interface
1735
+
1736
+ interface ConstructorProperties extends GObject.Object.ConstructorProperties {
1737
+
1738
+ // Own constructor properties of Json-1.0.Json.Reader
1739
+
1740
+ /**
1741
+ * The root of the JSON tree that the reader should read.
1742
+ */
1743
+ root?: Node | null
1744
+ }
1745
+
1746
+ }
1747
+
1748
+ interface Reader {
1749
+
1750
+ // Own properties of Json-1.0.Json.Reader
1751
+
1752
+ /**
1753
+ * The root of the JSON tree that the reader should read.
1754
+ */
1755
+ root: Node
1756
+
1757
+ // Owm methods of Json-1.0.Json.Reader
1758
+
1759
+ /**
1760
+ * Counts the elements of the current position, if the reader is
1761
+ * positioned on an array.
1762
+ *
1763
+ * In case of failure, the reader is set to an error state.
1764
+ * @returns the number of elements, or -1.
1765
+ */
1766
+ count_elements(): number
1767
+ /**
1768
+ * Counts the members of the current position, if the reader is
1769
+ * positioned on an object.
1770
+ *
1771
+ * In case of failure, the reader is set to an error state.
1772
+ * @returns the number of members, or -1
1773
+ */
1774
+ count_members(): number
1775
+ /**
1776
+ * Moves the cursor back to the previous node after being positioned
1777
+ * inside an array.
1778
+ *
1779
+ * This function resets the error state of the reader, if any was set.
1780
+ */
1781
+ end_element(): void
1782
+ /**
1783
+ * Moves the cursor back to the previous node after being positioned
1784
+ * inside an object.
1785
+ *
1786
+ * This function resets the error state of the reader, if any was set.
1787
+ */
1788
+ end_member(): void
1789
+ /**
1790
+ * Retrieves the boolean value of the current position of the reader.
1791
+ *
1792
+ * See also: [method`Json`.Reader.get_value]
1793
+ * @returns the boolean value
1794
+ */
1795
+ get_boolean_value(): boolean
1796
+ /**
1797
+ * Retrieves the reader node at the current position.
1798
+ * @returns the current node of the reader
1799
+ */
1800
+ get_current_node(): Node | null
1801
+ /**
1802
+ * Retrieves the floating point value of the current position of the reader.
1803
+ *
1804
+ * See also: [method`Json`.Reader.get_value]
1805
+ * @returns the floating point value
1806
+ */
1807
+ get_double_value(): number
1808
+ /**
1809
+ * Retrieves the error currently set on the reader.
1810
+ * @returns the current error
1811
+ */
1812
+ get_error(): GLib.Error | null
1813
+ /**
1814
+ * Retrieves the integer value of the current position of the reader.
1815
+ *
1816
+ * See also: [method`Json`.Reader.get_value]
1817
+ * @returns the integer value
1818
+ */
1819
+ get_int_value(): number
1820
+ /**
1821
+ * Retrieves the name of the current member.
1822
+ *
1823
+ * In case of failure, the reader is set to an error state.
1824
+ * @returns the name of the member
1825
+ */
1826
+ get_member_name(): string | null
1827
+ /**
1828
+ * Checks whether the value of the current position of the reader is `null`.
1829
+ *
1830
+ * See also: [method`Json`.Reader.get_value]
1831
+ * @returns `TRUE` if `null` is set, and `FALSE` otherwise
1832
+ */
1833
+ get_null_value(): boolean
1834
+ /**
1835
+ * Retrieves the string value of the current position of the reader.
1836
+ *
1837
+ * See also: [method`Json`.Reader.get_value]
1838
+ * @returns the string value
1839
+ */
1840
+ get_string_value(): string | null
1841
+ /**
1842
+ * Retrieves the value node at the current position of the reader.
1843
+ *
1844
+ * If the current position does not contain a scalar value, the reader
1845
+ * is set to an error state.
1846
+ * @returns the current value node
1847
+ */
1848
+ get_value(): Node | null
1849
+ /**
1850
+ * Checks whether the reader is currently on an array.
1851
+ * @returns `TRUE` if the reader is on an array
1852
+ */
1853
+ is_array(): boolean
1854
+ /**
1855
+ * Checks whether the reader is currently on an object.
1856
+ * @returns `TRUE` if the reader is on an object
1857
+ */
1858
+ is_object(): boolean
1859
+ /**
1860
+ * Checks whether the reader is currently on a value.
1861
+ * @returns `TRUE` if the reader is on a value
1862
+ */
1863
+ is_value(): boolean
1864
+ /**
1865
+ * Retrieves a list of member names from the current position, if the reader
1866
+ * is positioned on an object.
1867
+ *
1868
+ * In case of failure, the reader is set to an error state.
1869
+ * @returns the members of the object
1870
+ */
1871
+ list_members(): string[]
1872
+ /**
1873
+ * Advances the cursor of the reader to the element of the array or
1874
+ * the member of the object at the given position.
1875
+ *
1876
+ * You can use [method`Json`.Reader.get_value] and its wrapper functions to
1877
+ * retrieve the value of the element; for instance, the following code will
1878
+ * read the first element of the array at the current cursor position:
1879
+ *
1880
+ * ```c
1881
+ * json_reader_read_element (reader, 0);
1882
+ * int_value = json_reader_get_int_value (reader);
1883
+ * ```
1884
+ *
1885
+ * After reading the value, you should call [method`Json`.Reader.end_element]
1886
+ * to reposition the cursor inside the reader, e.g.:
1887
+ *
1888
+ * ```c
1889
+ * const char *str_value = NULL;
1890
+ *
1891
+ * json_reader_read_element (reader, 1);
1892
+ * str_value = json_reader_get_string_value (reader);
1893
+ * json_reader_end_element (reader);
1894
+ *
1895
+ * json_reader_read_element (reader, 2);
1896
+ * str_value = json_reader_get_string_value (reader);
1897
+ * json_reader_end_element (reader);
1898
+ * ```
1899
+ *
1900
+ * If the reader is not currently on an array or an object, or if the index is
1901
+ * bigger than the size of the array or the object, the reader will be
1902
+ * put in an error state until [method`Json`.Reader.end_element] is called. This
1903
+ * means that, if used conditionally, [method`Json`.Reader.end_element] must be
1904
+ * called on all branches:
1905
+ *
1906
+ * ```c
1907
+ * if (!json_reader_read_element (reader, 1))
1908
+ * {
1909
+ * g_propagate_error (error, json_reader_get_error (reader));
1910
+ * json_reader_end_element (reader);
1911
+ * return FALSE;
1912
+ * }
1913
+ * else
1914
+ * {
1915
+ * const char *str_value = json_reader_get_string_value (reader);
1916
+ * json_reader_end_element (reader);
1917
+ *
1918
+ * // use str_value
1919
+ *
1920
+ * return TRUE;
1921
+ * }
1922
+ * ```c
1923
+ * @param index_ the index of the element
1924
+ * @returns `TRUE` on success, and `FALSE` otherwise
1925
+ */
1926
+ read_element(index_: number): boolean
1927
+ /**
1928
+ * Advances the cursor of the reader to the `member_name` of the object at
1929
+ * the current position.
1930
+ *
1931
+ * You can use [method`Json`.Reader.get_value] and its wrapper functions to
1932
+ * retrieve the value of the member; for instance:
1933
+ *
1934
+ * ```c
1935
+ * json_reader_read_member (reader, "width");
1936
+ * width = json_reader_get_int_value (reader);
1937
+ * ```
1938
+ *
1939
+ * After reading the value, `json_reader_end_member()` should be called to
1940
+ * reposition the cursor inside the reader, e.g.:
1941
+ *
1942
+ * ```c
1943
+ * json_reader_read_member (reader, "author");
1944
+ * author = json_reader_get_string_value (reader);
1945
+ * json_reader_end_member (reader);
1946
+ *
1947
+ * json_reader_read_member (reader, "title");
1948
+ * title = json_reader_get_string_value (reader);
1949
+ * json_reader_end_member (reader);
1950
+ * ```
1951
+ *
1952
+ * If the reader is not currently on an object, or if the `member_name` is not
1953
+ * defined in the object, the reader will be put in an error state until
1954
+ * [method`Json`.Reader.end_member] is called. This means that if used
1955
+ * conditionally, [method`Json`.Reader.end_member] must be called on all branches:
1956
+ *
1957
+ * ```c
1958
+ * if (!json_reader_read_member (reader, "title"))
1959
+ * {
1960
+ * g_propagate_error (error, json_reader_get_error (reader));
1961
+ * json_reader_end_member (reader);
1962
+ * return FALSE;
1963
+ * }
1964
+ * else
1965
+ * {
1966
+ * const char *str_value = json_reader_get_string_value (reader);
1967
+ * json_reader_end_member (reader);
1968
+ *
1969
+ * // use str_value
1970
+ *
1971
+ * return TRUE;
1972
+ * }
1973
+ * ```
1974
+ * @param member_name the name of the member to read
1975
+ * @returns `TRUE` on success, and `FALSE` otherwise
1976
+ */
1977
+ read_member(member_name: string | null): boolean
1978
+ /**
1979
+ * Sets the root node of the JSON tree to be read by `reader`.
1980
+ *
1981
+ * The reader will take a copy of the node.
1982
+ * @param root the root node
1983
+ */
1984
+ set_root(root: Node | null): void
1985
+
1986
+ // Class property signals of Json-1.0.Json.Reader
1987
+
1988
+ connect(sigName: "notify::root", callback: (($obj: Reader, pspec: GObject.ParamSpec) => void)): number
1989
+ connect_after(sigName: "notify::root", callback: (($obj: Reader, pspec: GObject.ParamSpec) => void)): number
1990
+ emit(sigName: "notify::root", ...args: any[]): void
1991
+ connect(sigName: string, callback: (...args: any[]) => void): number
1992
+ connect_after(sigName: string, callback: (...args: any[]) => void): number
1993
+ emit(sigName: string, ...args: any[]): void
1994
+ disconnect(id: number): void
1995
+ }
1996
+
1997
+ /**
1998
+ * `JsonReader` provides a simple, cursor-based API for parsing a JSON DOM.
1999
+ *
2000
+ * It is similar, in spirit, to the XML Reader API.
2001
+ *
2002
+ * ## Using `JsonReader`
2003
+ *
2004
+ * ```c
2005
+ * g_autoptr(JsonParser) parser = json_parser_new ();
2006
+ *
2007
+ * // str is defined elsewhere
2008
+ * json_parser_load_from_data (parser, str, -1, NULL);
2009
+ *
2010
+ * g_autoptr(JsonReader) reader = json_reader_new (json_parser_get_root (parser));
2011
+ *
2012
+ * json_reader_read_member (reader, "url");
2013
+ * const char *url = json_reader_get_string_value (reader);
2014
+ * json_reader_end_member (reader);
2015
+ *
2016
+ * json_reader_read_member (reader, "size");
2017
+ * json_reader_read_element (reader, 0);
2018
+ * int width = json_reader_get_int_value (reader);
2019
+ * json_reader_end_element (reader);
2020
+ * json_reader_read_element (reader, 1);
2021
+ * int height = json_reader_get_int_value (reader);
2022
+ * json_reader_end_element (reader);
2023
+ * json_reader_end_member (reader);
2024
+ * ```
2025
+ *
2026
+ * ## Error handling
2027
+ *
2028
+ * In case of error, `JsonReader` will be set in an error state; all subsequent
2029
+ * calls will simply be ignored until a function that resets the error state is
2030
+ * called, e.g.:
2031
+ *
2032
+ * ```c
2033
+ * // ask for the 7th element; if the element does not exist, the
2034
+ * // reader will be put in an error state
2035
+ * json_reader_read_element (reader, 6);
2036
+ *
2037
+ * // in case of error, this will return NULL, otherwise it will
2038
+ * // return the value of the element
2039
+ * str = json_reader_get_string_value (value);
2040
+ *
2041
+ * // this function resets the error state if any was set
2042
+ * json_reader_end_element (reader);
2043
+ * ```
2044
+ *
2045
+ * If you want to detect the error state as soon as possible, you can use
2046
+ * [method`Json`.Reader.get_error]:
2047
+ *
2048
+ * ```c
2049
+ * // like the example above, but in this case we print out the
2050
+ * // error immediately
2051
+ * if (!json_reader_read_element (reader, 6))
2052
+ * {
2053
+ * const GError *error = json_reader_get_error (reader);
2054
+ * g_print ("Unable to read the element: %s", error->message);
2055
+ * }
2056
+ * ```
2057
+ * @class
2058
+ */
2059
+ class Reader extends GObject.Object {
2060
+
2061
+ // Own properties of Json-1.0.Json.Reader
2062
+
2063
+ static name: string
2064
+ static $gtype: GObject.GType<Reader>
2065
+
2066
+ // Constructors of Json-1.0.Json.Reader
2067
+
2068
+ constructor(config?: Reader.ConstructorProperties)
2069
+ /**
2070
+ * Creates a new reader.
2071
+ *
2072
+ * You can use this object to read the contents of the JSON tree starting
2073
+ * from the given node.
2074
+ * @constructor
2075
+ * @param node the root node
2076
+ * @returns the newly created reader
2077
+ */
2078
+ constructor(node: Node | null)
2079
+ /**
2080
+ * Creates a new reader.
2081
+ *
2082
+ * You can use this object to read the contents of the JSON tree starting
2083
+ * from the given node.
2084
+ * @constructor
2085
+ * @param node the root node
2086
+ * @returns the newly created reader
2087
+ */
2088
+ static new(node: Node | null): Reader
2089
+ _init(config?: Reader.ConstructorProperties): void
2090
+ }
2091
+
2092
+ interface Array {
2093
+
2094
+ // Owm methods of Json-1.0.Json.Array
2095
+
2096
+ /**
2097
+ * Conveniently adds an array element into an array.
2098
+ *
2099
+ * If `value` is `NULL`, a `null` element will be added instead.
2100
+ *
2101
+ * See also: [method`Json`.Array.add_element], [method`Json`.Node.take_array]
2102
+ * @param value the array to add
2103
+ */
2104
+ add_array_element(value: Array | null): void
2105
+ /**
2106
+ * Conveniently adds the given boolean value into an array.
2107
+ *
2108
+ * See also: [method`Json`.Array.add_element], [method`Json`.Node.set_boolean]
2109
+ * @param value the boolean value to add
2110
+ */
2111
+ add_boolean_element(value: boolean): void
2112
+ /**
2113
+ * Conveniently adds the given floating point value into an array.
2114
+ *
2115
+ * See also: [method`Json`.Array.add_element], [method`Json`.Node.set_double]
2116
+ * @param value the floating point value to add
2117
+ */
2118
+ add_double_element(value: number): void
2119
+ /**
2120
+ * Appends the given `node` inside an array.
2121
+ * @param node the element to add
2122
+ */
2123
+ add_element(node: Node): void
2124
+ /**
2125
+ * Conveniently adds the given integer value into an array.
2126
+ *
2127
+ * See also: [method`Json`.Array.add_element], [method`Json`.Node.set_int]
2128
+ * @param value the integer value to add
2129
+ */
2130
+ add_int_element(value: number): void
2131
+ /**
2132
+ * Conveniently adds a `null` element into an array
2133
+ *
2134
+ * See also: [method`Json`.Array.add_element], `JSON_NODE_NULL`
2135
+ */
2136
+ add_null_element(): void
2137
+ /**
2138
+ * Conveniently adds an object into an array.
2139
+ *
2140
+ * If `value` is `NULL`, a `null` element will be added instead.
2141
+ *
2142
+ * See also: [method`Json`.Array.add_element], [method`Json`.Node.take_object]
2143
+ * @param value the object to add
2144
+ */
2145
+ add_object_element(value: Object | null): void
2146
+ /**
2147
+ * Conveniently adds the given string value into an array.
2148
+ *
2149
+ * See also: [method`Json`.Array.add_element], [method`Json`.Node.set_string]
2150
+ * @param value the string value to add
2151
+ */
2152
+ add_string_element(value: string | null): void
2153
+ /**
2154
+ * Retrieves a copy of the element at the given position in the array.
2155
+ * @param index_ the index of the element to retrieve
2156
+ * @returns a copy of the element at the given position
2157
+ */
2158
+ dup_element(index_: number): Node
2159
+ /**
2160
+ * Check whether two arrays are equal.
2161
+ *
2162
+ * Equality is defined as:
2163
+ *
2164
+ * - the array have the same number of elements
2165
+ * - the values of elements in corresponding positions are equal
2166
+ * @param b another JSON array
2167
+ * @returns `TRUE` if the arrays are equal, and `FALSE` otherwise
2168
+ */
2169
+ equal(b: Array): boolean
2170
+ /**
2171
+ * Iterates over all elements of an array, and calls a function on
2172
+ * each one of them.
2173
+ *
2174
+ * It is safe to change the value of an element of the array while
2175
+ * iterating over it, but it is not safe to add or remove elements
2176
+ * from the array.
2177
+ * @param func the function to be called on each element
2178
+ */
2179
+ foreach_element(func: ArrayForeach): void
2180
+ /**
2181
+ * Conveniently retrieves the array at the given position inside an array.
2182
+ *
2183
+ * See also: [method`Json`.Array.get_element], [method`Json`.Node.get_array]
2184
+ * @param index_ the index of the element to retrieve
2185
+ * @returns the array
2186
+ */
2187
+ get_array_element(index_: number): Array
2188
+ /**
2189
+ * Conveniently retrieves the boolean value of the element at the given
2190
+ * position inside an array.
2191
+ *
2192
+ * See also: [method`Json`.Array.get_element], [method`Json`.Node.get_boolean]
2193
+ * @param index_ the index of the element to retrieve
2194
+ * @returns the boolean value
2195
+ */
2196
+ get_boolean_element(index_: number): boolean
2197
+ /**
2198
+ * Conveniently retrieves the floating point value of the element at
2199
+ * the given position inside an array.
2200
+ *
2201
+ * See also: [method`Json`.Array.get_element], [method`Json`.Node.get_double]
2202
+ * @param index_ the index of the element to retrieve
2203
+ * @returns the floating point value
2204
+ */
2205
+ get_double_element(index_: number): number
2206
+ /**
2207
+ * Retrieves the element at the given position in the array.
2208
+ * @param index_ the index of the element to retrieve
2209
+ * @returns the element at the given position
2210
+ */
2211
+ get_element(index_: number): Node
2212
+ /**
2213
+ * Retrieves all the elements of an array as a list of nodes.
2214
+ * @returns the elements of the array
2215
+ */
2216
+ get_elements(): Node[] | null
2217
+ /**
2218
+ * Conveniently retrieves the integer value of the element at the given
2219
+ * position inside an array.
2220
+ *
2221
+ * See also: [method`Json`.Array.get_element], [method`Json`.Node.get_int]
2222
+ * @param index_ the index of the element to retrieve
2223
+ * @returns the integer value
2224
+ */
2225
+ get_int_element(index_: number): number
2226
+ /**
2227
+ * Retrieves the length of the given array
2228
+ * @returns the length of the array
2229
+ */
2230
+ get_length(): number
2231
+ /**
2232
+ * Conveniently checks whether the element at the given position inside the
2233
+ * array contains a `null` value.
2234
+ *
2235
+ * See also: [method`Json`.Array.get_element], [method`Json`.Node.is_null]
2236
+ * @param index_ the index of the element to retrieve
2237
+ * @returns `TRUE` if the element is `null`
2238
+ */
2239
+ get_null_element(index_: number): boolean
2240
+ /**
2241
+ * Conveniently retrieves the object at the given position inside an array.
2242
+ *
2243
+ * See also: [method`Json`.Array.get_element], [method`Json`.Node.get_object]
2244
+ * @param index_ the index of the element to retrieve
2245
+ * @returns the object
2246
+ */
2247
+ get_object_element(index_: number): Object
2248
+ /**
2249
+ * Conveniently retrieves the string value of the element at the given
2250
+ * position inside an array.
2251
+ *
2252
+ * See also: [method`Json`.Array.get_element], [method`Json`.Node.get_string]
2253
+ * @param index_ the index of the element to retrieve
2254
+ * @returns the string value
2255
+ */
2256
+ get_string_element(index_: number): string | null
2257
+ /**
2258
+ * Calculates a hash value for the given `key`.
2259
+ *
2260
+ * The hash is calculated over the array and all its elements, recursively.
2261
+ *
2262
+ * If the array is immutable, this is a fast operation; otherwise, it scales
2263
+ * proportionally with the length of the array.
2264
+ * @returns hash value for the key
2265
+ */
2266
+ hash(): number
2267
+ /**
2268
+ * Check whether the given `array` has been marked as immutable by calling
2269
+ * [method`Json`.Array.seal] on it.
2270
+ * @returns %TRUE if the array is immutable
2271
+ */
2272
+ is_immutable(): boolean
2273
+ /**
2274
+ * Acquires a reference on the given array.
2275
+ * @returns the passed array, with the reference count increased by one
2276
+ */
2277
+ ref(): Array
2278
+ /**
2279
+ * Removes the element at the given position inside an array.
2280
+ *
2281
+ * This function will release the reference held on the element.
2282
+ * @param index_ the position of the element to be removed
2283
+ */
2284
+ remove_element(index_: number): void
2285
+ /**
2286
+ * Seals the given array, making it immutable to further changes.
2287
+ *
2288
+ * This function will recursively seal all elements in the array too.
2289
+ *
2290
+ * If the `array` is already immutable, this is a no-op.
2291
+ */
2292
+ seal(): void
2293
+ /**
2294
+ * Releases a reference on the given array.
2295
+ *
2296
+ * If the reference count reaches zero, the array is destroyed and all
2297
+ * its allocated resources are freed.
2298
+ */
2299
+ unref(): void
2300
+ }
2301
+
2302
+ /**
2303
+ * `JsonArray` is the representation of the array type inside JSON.
2304
+ *
2305
+ * A `JsonArray` contains [struct`Json`.Node] elements, which may contain
2306
+ * fundamental types, other arrays or objects.
2307
+ *
2308
+ * Since arrays can be arbitrarily big, copying them can be expensive; for
2309
+ * this reason, they are reference counted. You can control the lifetime of
2310
+ * a `JsonArray` using [method`Json`.Array.ref] and [method`Json`.Array.unref].
2311
+ *
2312
+ * To append an element, use [method`Json`.Array.add_element].
2313
+ *
2314
+ * To extract an element at a given index, use [method`Json`.Array.get_element].
2315
+ *
2316
+ * To retrieve the entire array in list form, use [method`Json`.Array.get_elements].
2317
+ *
2318
+ * To retrieve the length of the array, use [method`Json`.Array.get_length].
2319
+ * @record
2320
+ */
2321
+ class Array {
2322
+
2323
+ // Own properties of Json-1.0.Json.Array
2324
+
2325
+ static name: string
2326
+
2327
+ // Constructors of Json-1.0.Json.Array
2328
+
2329
+ /**
2330
+ * Creates a new array.
2331
+ * @constructor
2332
+ * @returns the newly created array
2333
+ */
2334
+ constructor()
2335
+ /**
2336
+ * Creates a new array.
2337
+ * @constructor
2338
+ * @returns the newly created array
2339
+ */
2340
+ static new(): Array
2341
+ /**
2342
+ * Creates a new array with `n_elements` slots already allocated.
2343
+ * @constructor
2344
+ * @param n_elements number of slots to pre-allocate
2345
+ * @returns the newly created array
2346
+ */
2347
+ static sized_new(n_elements: number): Array
2348
+ }
2349
+
2350
+ interface BuilderClass {
2351
+ }
2352
+
2353
+ abstract class BuilderClass {
2354
+
2355
+ // Own properties of Json-1.0.Json.BuilderClass
2356
+
2357
+ static name: string
2358
+ }
2359
+
2360
+ interface BuilderPrivate {
2361
+ }
2362
+
2363
+ class BuilderPrivate {
2364
+
2365
+ // Own properties of Json-1.0.Json.BuilderPrivate
2366
+
2367
+ static name: string
2368
+ }
2369
+
2370
+ interface GeneratorClass {
2371
+ }
2372
+
2373
+ abstract class GeneratorClass {
2374
+
2375
+ // Own properties of Json-1.0.Json.GeneratorClass
2376
+
2377
+ static name: string
2378
+ }
2379
+
2380
+ interface GeneratorPrivate {
2381
+ }
2382
+
2383
+ class GeneratorPrivate {
2384
+
2385
+ // Own properties of Json-1.0.Json.GeneratorPrivate
2386
+
2387
+ static name: string
2388
+ }
2389
+
2390
+ interface Node {
2391
+
2392
+ // Owm methods of Json-1.0.Json.Node
2393
+
2394
+ /**
2395
+ * Copies `node`.
2396
+ *
2397
+ * If the node contains complex data types, their reference
2398
+ * counts are increased, regardless of whether the node is mutable or
2399
+ * immutable.
2400
+ *
2401
+ * The copy will be immutable if, and only if, `node` is immutable. However,
2402
+ * there should be no need to copy an immutable node.
2403
+ * @returns the copied of the given node
2404
+ */
2405
+ copy(): Node
2406
+ /**
2407
+ * Retrieves the JSON array inside `node`.
2408
+ *
2409
+ * The reference count of the returned array is increased.
2410
+ *
2411
+ * It is a programmer error to call this on a node which doesn’t hold an
2412
+ * array value. Use `JSON_NODE_HOLDS_ARRAY` first.
2413
+ * @returns the JSON array with its reference count increased.
2414
+ */
2415
+ dup_array(): Array | null
2416
+ /**
2417
+ * Retrieves the object inside `node`.
2418
+ *
2419
+ * The reference count of the returned object is increased.
2420
+ *
2421
+ * It is a programmer error to call this on a node which doesn’t hold an
2422
+ * object value. Use `JSON_NODE_HOLDS_OBJECT` first.
2423
+ * @returns the JSON object
2424
+ */
2425
+ dup_object(): Object | null
2426
+ /**
2427
+ * Gets a copy of the string value stored inside a node.
2428
+ *
2429
+ * If the node does not hold a string value, `NULL` is returned.
2430
+ * @returns a copy of the string inside the node
2431
+ */
2432
+ dup_string(): string | null
2433
+ /**
2434
+ * Check whether `a` and `b` are equal node, meaning they have the same
2435
+ * type and same values (checked recursively).
2436
+ *
2437
+ * Note that integer values are compared numerically, ignoring type, so a
2438
+ * double value 4.0 is equal to the integer value 4.
2439
+ * @param b another JSON node
2440
+ * @returns `TRUE` if @a and @b are equal; `FALSE` otherwise
2441
+ */
2442
+ equal(b: Node): boolean
2443
+ /**
2444
+ * Frees the resources allocated by the node.
2445
+ */
2446
+ free(): void
2447
+ /**
2448
+ * Retrieves the JSON array stored inside a node.
2449
+ *
2450
+ * It is a programmer error to call this on a node which doesn’t hold an
2451
+ * array value. Use `JSON_NODE_HOLDS_ARRAY` first.
2452
+ * @returns the JSON array
2453
+ */
2454
+ get_array(): Array | null
2455
+ /**
2456
+ * Gets the boolean value stored inside a node.
2457
+ *
2458
+ * If the node holds an integer or double value which is zero, `FALSE` is
2459
+ * returned; otherwise `TRUE` is returned.
2460
+ *
2461
+ * If the node holds a `JSON_NODE_NULL` value or a value of another
2462
+ * non-boolean type, `FALSE` is returned.
2463
+ * @returns a boolean value.
2464
+ */
2465
+ get_boolean(): boolean
2466
+ /**
2467
+ * Gets the double value stored inside a node.
2468
+ *
2469
+ * If the node holds an integer value, it is returned as a double.
2470
+ *
2471
+ * If the node holds a `FALSE` boolean value, `0.0` is returned; otherwise
2472
+ * a non-zero double is returned.
2473
+ *
2474
+ * If the node holds a `JSON_NODE_NULL` value or a value of another
2475
+ * non-double type, `0.0` is returned.
2476
+ * @returns a double value.
2477
+ */
2478
+ get_double(): number
2479
+ /**
2480
+ * Gets the integer value stored inside a node.
2481
+ *
2482
+ * If the node holds a double value, its integer component is returned.
2483
+ *
2484
+ * If the node holds a `FALSE` boolean value, `0` is returned; otherwise,
2485
+ * a non-zero integer is returned.
2486
+ *
2487
+ * If the node holds a `JSON_NODE_NULL` value or a value of another
2488
+ * non-integer type, `0` is returned.
2489
+ * @returns an integer value.
2490
+ */
2491
+ get_int(): number
2492
+ /**
2493
+ * Retrieves the type of a `node`.
2494
+ * @returns the type of the node
2495
+ */
2496
+ get_node_type(): NodeType
2497
+ /**
2498
+ * Retrieves the object stored inside a node.
2499
+ *
2500
+ * It is a programmer error to call this on a node which doesn’t hold an
2501
+ * object value. Use `JSON_NODE_HOLDS_OBJECT` first.
2502
+ * @returns the JSON object
2503
+ */
2504
+ get_object(): Object | null
2505
+ /**
2506
+ * Retrieves the parent node of the given `node`.
2507
+ * @returns the parent node, or `NULL` if @node is the root node
2508
+ */
2509
+ get_parent(): Node | null
2510
+ /**
2511
+ * Gets the string value stored inside a node.
2512
+ *
2513
+ * If the node does not hold a string value, `NULL` is returned.
2514
+ * @returns a string value.
2515
+ */
2516
+ get_string(): string | null
2517
+ /**
2518
+ * Retrieves a value from a node and copies into `value`.
2519
+ *
2520
+ * When done using it, call `g_value_unset()` on the `GValue` to free the
2521
+ * associated resources.
2522
+ *
2523
+ * It is a programmer error to call this on a node which doesn’t hold a scalar
2524
+ * value. Use `JSON_NODE_HOLDS_VALUE` first.
2525
+ */
2526
+ get_value(): /* value */ any
2527
+ /**
2528
+ * Returns the `GType` of the payload of the node.
2529
+ *
2530
+ * For `JSON_NODE_NULL` nodes, the returned type is `G_TYPE_INVALID`.
2531
+ * @returns the type for the payload
2532
+ */
2533
+ get_value_type(): GObject.GType
2534
+ /**
2535
+ * Calculate a hash value for the given `key`.
2536
+ *
2537
+ * The hash is calculated over the node and its value, recursively. If the node
2538
+ * is immutable, this is a fast operation; otherwise, it scales proportionally
2539
+ * with the size of the node’s value (for example, with the number of members
2540
+ * in the JSON object if this node contains an object).
2541
+ * @returns hash value for @key
2542
+ */
2543
+ hash(): number
2544
+ /**
2545
+ * Initializes a `node` to a specific `type`.
2546
+ *
2547
+ * If the node has already been initialized once, it will be reset to
2548
+ * the given type, and any data contained will be cleared.
2549
+ * @param type the type of JSON node to initialize `node` to
2550
+ * @returns the initialized node
2551
+ */
2552
+ init(type: NodeType): Node
2553
+ /**
2554
+ * Initializes `node` to `JSON_NODE_ARRAY` and sets `array` into it.
2555
+ *
2556
+ * This function will take a reference on `array`.
2557
+ *
2558
+ * If the node has already been initialized once, it will be reset to
2559
+ * the given type, and any data contained will be cleared.
2560
+ * @param array the JSON array to initialize `node` with, or `NULL`
2561
+ * @returns the initialized node
2562
+ */
2563
+ init_array(array: Array | null): Node
2564
+ /**
2565
+ * Initializes `node` to `JSON_NODE_VALUE` and sets `value` into it.
2566
+ *
2567
+ * If the node has already been initialized once, it will be reset to
2568
+ * the given type, and any data contained will be cleared.
2569
+ * @param value a boolean value
2570
+ * @returns the initialized node
2571
+ */
2572
+ init_boolean(value: boolean): Node
2573
+ /**
2574
+ * Initializes `node` to `JSON_NODE_VALUE` and sets `value` into it.
2575
+ *
2576
+ * If the node has already been initialized once, it will be reset to
2577
+ * the given type, and any data contained will be cleared.
2578
+ * @param value a floating point value
2579
+ * @returns the initialized node
2580
+ */
2581
+ init_double(value: number): Node
2582
+ /**
2583
+ * Initializes `node` to `JSON_NODE_VALUE` and sets `value` into it.
2584
+ *
2585
+ * If the node has already been initialized once, it will be reset to
2586
+ * the given type, and any data contained will be cleared.
2587
+ * @param value an integer
2588
+ * @returns the initialized node
2589
+ */
2590
+ init_int(value: number): Node
2591
+ /**
2592
+ * Initializes `node` to `JSON_NODE_NULL`.
2593
+ *
2594
+ * If the node has already been initialized once, it will be reset to
2595
+ * the given type, and any data contained will be cleared.
2596
+ * @returns the initialized node
2597
+ */
2598
+ init_null(): Node
2599
+ /**
2600
+ * Initializes `node` to `JSON_NODE_OBJECT` and sets `object` into it.
2601
+ *
2602
+ * This function will take a reference on `object`.
2603
+ *
2604
+ * If the node has already been initialized once, it will be reset to
2605
+ * the given type, and any data contained will be cleared.
2606
+ * @param object the JSON object to initialize `node` with, or `NULL`
2607
+ * @returns the initialized node
2608
+ */
2609
+ init_object(object: Object | null): Node
2610
+ /**
2611
+ * Initializes `node` to `JSON_NODE_VALUE` and sets `value` into it.
2612
+ *
2613
+ * If the node has already been initialized once, it will be reset to
2614
+ * the given type, and any data contained will be cleared.
2615
+ * @param value a string value
2616
+ * @returns the initialized node
2617
+ */
2618
+ init_string(value: string | null): Node
2619
+ /**
2620
+ * Check whether the given `node` has been marked as immutable by calling
2621
+ * [method`Json`.Node.seal] on it.
2622
+ * @returns `TRUE` if the @node is immutable
2623
+ */
2624
+ is_immutable(): boolean
2625
+ /**
2626
+ * Checks whether `node` is a `JSON_NODE_NULL`.
2627
+ *
2628
+ * A `JSON_NODE_NULL` node is not the same as a `NULL` node; a `JSON_NODE_NULL`
2629
+ * represents a literal `null` value in the JSON tree.
2630
+ * @returns `TRUE` if the node is null
2631
+ */
2632
+ is_null(): boolean
2633
+ /**
2634
+ * Increments the reference count of `node`.
2635
+ * @returns a pointer to @node
2636
+ */
2637
+ ref(): Node
2638
+ /**
2639
+ * Seals the given node, making it immutable to further changes.
2640
+ *
2641
+ * In order to be sealed, the `node` must have a type and value set. The value
2642
+ * will be recursively sealed — if the node holds an object, that JSON object
2643
+ * will be sealed, etc.
2644
+ *
2645
+ * If the `node` is already immutable, this is a no-op.
2646
+ */
2647
+ seal(): void
2648
+ /**
2649
+ * Sets `array` inside `node`.
2650
+ *
2651
+ * The reference count of `array` is increased.
2652
+ *
2653
+ * It is a programmer error to call this on a node which doesn’t hold an
2654
+ * array value. Use `JSON_NODE_HOLDS_ARRAY` first.
2655
+ * @param array a JSON array
2656
+ */
2657
+ set_array(array: Array): void
2658
+ /**
2659
+ * Sets `value` as the boolean content of the `node,` replacing any existing
2660
+ * content.
2661
+ *
2662
+ * It is an error to call this on an immutable node, or on a node which is not
2663
+ * a value node.
2664
+ * @param value a boolean value
2665
+ */
2666
+ set_boolean(value: boolean): void
2667
+ /**
2668
+ * Sets `value` as the double content of the `node,` replacing any existing
2669
+ * content.
2670
+ *
2671
+ * It is an error to call this on an immutable node, or on a node which is not
2672
+ * a value node.
2673
+ * @param value a double value
2674
+ */
2675
+ set_double(value: number): void
2676
+ /**
2677
+ * Sets `value` as the integer content of the `node,` replacing any existing
2678
+ * content.
2679
+ *
2680
+ * It is an error to call this on an immutable node, or on a node which is not
2681
+ * a value node.
2682
+ * @param value an integer value
2683
+ */
2684
+ set_int(value: number): void
2685
+ /**
2686
+ * Sets `objects` inside `node`.
2687
+ *
2688
+ * The reference count of `object` is increased.
2689
+ *
2690
+ * If `object` is `NULL`, the node’s existing object is cleared.
2691
+ *
2692
+ * It is an error to call this on an immutable node, or on a node which is not
2693
+ * an object node.
2694
+ * @param object a JSON object
2695
+ */
2696
+ set_object(object: Object | null): void
2697
+ /**
2698
+ * Sets the parent node for the given `node`.
2699
+ *
2700
+ * It is an error to call this with an immutable `parent`.
2701
+ *
2702
+ * The `node` may be immutable.
2703
+ * @param parent the parent node
2704
+ */
2705
+ set_parent(parent: Node | null): void
2706
+ /**
2707
+ * Sets `value` as the string content of the `node,` replacing any existing
2708
+ * content.
2709
+ *
2710
+ * It is an error to call this on an immutable node, or on a node which is not
2711
+ * a value node.
2712
+ * @param value a string value
2713
+ */
2714
+ set_string(value: string | null): void
2715
+ /**
2716
+ * Sets a scalar value inside the given node.
2717
+ *
2718
+ * The contents of the given `GValue` are copied into the `JsonNode`.
2719
+ *
2720
+ * The following `GValue` types have a direct mapping to JSON types:
2721
+ *
2722
+ * - `G_TYPE_INT64`
2723
+ * - `G_TYPE_DOUBLE`
2724
+ * - `G_TYPE_BOOLEAN`
2725
+ * - `G_TYPE_STRING`
2726
+ *
2727
+ * JSON-GLib will also automatically promote the following `GValue` types:
2728
+ *
2729
+ * - `G_TYPE_INT` to `G_TYPE_INT64`
2730
+ * - `G_TYPE_FLOAT` to `G_TYPE_DOUBLE`
2731
+ *
2732
+ * It is an error to call this on an immutable node, or on a node which is not
2733
+ * a value node.
2734
+ * @param value the value to set
2735
+ */
2736
+ set_value(value: any): void
2737
+ /**
2738
+ * Sets `array` inside `node`.
2739
+ *
2740
+ * The reference count of `array` is not increased.
2741
+ *
2742
+ * It is a programmer error to call this on a node which doesn’t hold an
2743
+ * array value. Use `JSON_NODE_HOLDS_ARRAY` first.
2744
+ * @param array a JSON array
2745
+ */
2746
+ take_array(array: Array): void
2747
+ /**
2748
+ * Sets `object` inside `node`.
2749
+ *
2750
+ * The reference count of `object` is not increased.
2751
+ *
2752
+ * It is an error to call this on an immutable node, or on a node which is not
2753
+ * an object node.
2754
+ * @param object a JSON object
2755
+ */
2756
+ take_object(object: Object): void
2757
+ /**
2758
+ * Retrieves the user readable name of the data type contained by `node`.
2759
+ *
2760
+ * **Note**: The name is only meant for debugging purposes, and there is no
2761
+ * guarantee the name will stay the same across different versions.
2762
+ * @returns a string containing the name of the type
2763
+ */
2764
+ type_name(): string | null
2765
+ /**
2766
+ * Decrements the reference count of `node`.
2767
+ *
2768
+ * If the reference count reaches zero, the node is freed.
2769
+ */
2770
+ unref(): void
2771
+ }
2772
+
2773
+ /**
2774
+ * A generic container of JSON data types.
2775
+ *
2776
+ * `JsonNode` can contain fundamental types (integers, booleans, floating point
2777
+ * numbers, strings) and complex types (arrays and objects).
2778
+ *
2779
+ * When parsing a JSON data stream you extract the root node and walk
2780
+ * the node tree by retrieving the type of data contained inside the
2781
+ * node with the `JSON_NODE_TYPE` macro. If the node contains a fundamental
2782
+ * type you can retrieve a copy of the `GValue` holding it with the
2783
+ * [method`Json`.Node.get_value] function, and then use the `GValue` API to extract
2784
+ * the data; if the node contains a complex type you can retrieve the
2785
+ * [struct`Json`.Object] or the [struct`Json`.Array] using [method`Json`.Node.get_object]
2786
+ * or [method`Json`.Node.get_array] respectively, and then retrieve the nodes
2787
+ * they contain.
2788
+ *
2789
+ * A `JsonNode` may be marked as immutable using [method`Json`.Node.seal]. This
2790
+ * marks the node and all its descendents as read-only, and means that
2791
+ * subsequent calls to setter functions (such as [method`Json`.Node.set_array])
2792
+ * on them will abort as a programmer error. By marking a node tree as
2793
+ * immutable, it may be referenced in multiple places and its hash value cached
2794
+ * for fast lookups, without the possibility of a value deep within the tree
2795
+ * changing and affecting hash values. Immutable nodes may be passed to
2796
+ * functions which retain a reference to them without needing to take a copy.
2797
+ *
2798
+ * A `JsonNode` supports two types of memory management: `malloc`/`free`
2799
+ * semantics, and reference counting semantics. The two may be mixed to a
2800
+ * limited extent: nodes may be allocated (which gives them a reference count
2801
+ * of 1), referenced one or more times, unreferenced exactly that number of
2802
+ * times (using [method`Json`.Node.unref]), then either unreferenced exactly
2803
+ * once more or freed (using [method`Json`.Node.free]) to destroy them.
2804
+ * The [method`Json`.Node.free] function must not be used when a node might
2805
+ * have a reference count not equal to 1. To this end, JSON-GLib uses
2806
+ * [method`Json`.Node.copy] and [method`Json`.Node.unref] internally.
2807
+ * @record
2808
+ */
2809
+ class Node {
2810
+
2811
+ // Own properties of Json-1.0.Json.Node
2812
+
2813
+ static name: string
2814
+
2815
+ // Constructors of Json-1.0.Json.Node
2816
+
2817
+ /**
2818
+ * Allocates a new, uninitialized node.
2819
+ *
2820
+ * Use [method`Json`.Node.init] and its variants to initialize the returned value.
2821
+ * @constructor
2822
+ * @returns the newly allocated node
2823
+ */
2824
+ static alloc(): Node
2825
+ /**
2826
+ * Creates a new node holding the given `type`.
2827
+ *
2828
+ * This is a convenience function for [ctor`Json`.Node.alloc] and
2829
+ * [method`Json`.Node.init], and it's the equivalent of:
2830
+ *
2831
+ * ```c
2832
+ * json_node_init (json_node_alloc (), type);
2833
+ * ```
2834
+ * @constructor
2835
+ * @param type the type of the node to create
2836
+ * @returns the newly created node
2837
+ */
2838
+ constructor(type: NodeType)
2839
+ /**
2840
+ * Creates a new node holding the given `type`.
2841
+ *
2842
+ * This is a convenience function for [ctor`Json`.Node.alloc] and
2843
+ * [method`Json`.Node.init], and it's the equivalent of:
2844
+ *
2845
+ * ```c
2846
+ * json_node_init (json_node_alloc (), type);
2847
+ * ```
2848
+ * @constructor
2849
+ * @param type the type of the node to create
2850
+ * @returns the newly created node
2851
+ */
2852
+ static new(type: NodeType): Node
2853
+ }
2854
+
2855
+ interface Object {
2856
+
2857
+ // Owm methods of Json-1.0.Json.Object
2858
+
2859
+ /**
2860
+ * Adds a new member for the given name and value into an object.
2861
+ *
2862
+ * This function will return if the object already contains a member
2863
+ * with the same name.
2864
+ * @param member_name the name of the member
2865
+ * @param node the value of the member
2866
+ */
2867
+ add_member(member_name: string | null, node: Node): void
2868
+ /**
2869
+ * Retrieves a copy of the value of the given member inside an object.
2870
+ * @param member_name the name of the JSON object member to access
2871
+ * @returns a copy of the value for the requested object member
2872
+ */
2873
+ dup_member(member_name: string | null): Node | null
2874
+ /**
2875
+ * Check whether `a` and `b` are equal objects, meaning they have the same
2876
+ * set of members, and the values of corresponding members are equal.
2877
+ * @param b another JSON object
2878
+ * @returns `TRUE` if @a and @b are equal, and `FALSE` otherwise
2879
+ */
2880
+ equal(b: Object): boolean
2881
+ /**
2882
+ * Iterates over all members of `object` and calls `func` on
2883
+ * each one of them.
2884
+ *
2885
+ * It is safe to change the value of a member of the oobject
2886
+ * from within the iterator function, but it is not safe to add or
2887
+ * remove members from the object.
2888
+ *
2889
+ * The order in which the object members are iterated is the
2890
+ * insertion order.
2891
+ * @param func the function to be called on each member
2892
+ */
2893
+ foreach_member(func: ObjectForeach): void
2894
+ /**
2895
+ * Convenience function that retrieves the array
2896
+ * stored in `member_name` of `object`. It is an error to specify a
2897
+ * `member_name` which does not exist.
2898
+ *
2899
+ * If `member_name` contains `null`, then this function will return `NULL`.
2900
+ *
2901
+ * See also: [method`Json`.Object.get_member], [method`Json`.Object.has_member]
2902
+ * @param member_name the name of the member
2903
+ * @returns the array inside the object's member
2904
+ */
2905
+ get_array_member(member_name: string | null): Array | null
2906
+ /**
2907
+ * Convenience function that retrieves the boolean value
2908
+ * stored in `member_name` of `object`. It is an error to specify a
2909
+ * `member_name` which does not exist.
2910
+ *
2911
+ * See also: [method`Json`.Object.get_boolean_member_with_default],
2912
+ * [method`Json`.Object.get_member], [method`Json`.Object.has_member]
2913
+ * @param member_name the name of the member
2914
+ * @returns the boolean value of the object's member
2915
+ */
2916
+ get_boolean_member(member_name: string | null): boolean
2917
+ /**
2918
+ * Convenience function that retrieves the boolean value
2919
+ * stored in `member_name` of `object`.
2920
+ *
2921
+ * If `member_name` does not exist, does not contain a scalar value,
2922
+ * or contains `null`, then `default_value` is returned instead.
2923
+ * @param member_name the name of the `object` member
2924
+ * @param default_value the value to return if `member_name` is not valid
2925
+ * @returns the boolean value of the object's member, or the given default
2926
+ */
2927
+ get_boolean_member_with_default(member_name: string | null, default_value: boolean): boolean
2928
+ /**
2929
+ * Convenience function that retrieves the floating point value
2930
+ * stored in `member_name` of `object`. It is an error to specify a
2931
+ * `member_name` which does not exist.
2932
+ *
2933
+ * See also: [method`Json`.Object.get_double_member_with_default],
2934
+ * [method`Json`.Object.get_member], [method`Json`.Object.has_member]
2935
+ * @param member_name the name of the member
2936
+ * @returns the floating point value of the object's member
2937
+ */
2938
+ get_double_member(member_name: string | null): number
2939
+ /**
2940
+ * Convenience function that retrieves the floating point value
2941
+ * stored in `member_name` of `object`.
2942
+ *
2943
+ * If `member_name` does not exist, does not contain a scalar value,
2944
+ * or contains `null`, then `default_value` is returned instead.
2945
+ * @param member_name the name of the `object` member
2946
+ * @param default_value the value to return if `member_name` is not valid
2947
+ * @returns the floating point value of the object's member, or the given default
2948
+ */
2949
+ get_double_member_with_default(member_name: string | null, default_value: number): number
2950
+ /**
2951
+ * Convenience function that retrieves the integer value
2952
+ * stored in `member_name` of `object`. It is an error to specify a
2953
+ * `member_name` which does not exist.
2954
+ *
2955
+ * See also: [method`Json`.Object.get_int_member_with_default],
2956
+ * [method`Json`.Object.get_member], [method`Json`.Object.has_member]
2957
+ * @param member_name the name of the object member
2958
+ * @returns the integer value of the object's member
2959
+ */
2960
+ get_int_member(member_name: string | null): number
2961
+ /**
2962
+ * Convenience function that retrieves the integer value
2963
+ * stored in `member_name` of `object`.
2964
+ *
2965
+ * If `member_name` does not exist, does not contain a scalar value,
2966
+ * or contains `null`, then `default_value` is returned instead.
2967
+ * @param member_name the name of the object member
2968
+ * @param default_value the value to return if `member_name` is not valid
2969
+ * @returns the integer value of the object's member, or the given default
2970
+ */
2971
+ get_int_member_with_default(member_name: string | null, default_value: number): number
2972
+ /**
2973
+ * Retrieves the value of the given member inside an object.
2974
+ * @param member_name the name of the JSON object member to access
2975
+ * @returns the value for the requested object member
2976
+ */
2977
+ get_member(member_name: string | null): Node | null
2978
+ /**
2979
+ * Retrieves all the names of the members of an object.
2980
+ *
2981
+ * You can obtain the value for each member by iterating the returned list
2982
+ * and calling [method`Json`.Object.get_member].
2983
+ * @returns the member names of the object
2984
+ */
2985
+ get_members(): string[] | null
2986
+ /**
2987
+ * Convenience function that checks whether the value
2988
+ * stored in `member_name` of `object` is null. It is an error to
2989
+ * specify a `member_name` which does not exist.
2990
+ *
2991
+ * See also: [method`Json`.Object.get_member], [method`Json`.Object.has_member]
2992
+ * @param member_name the name of the member
2993
+ * @returns `TRUE` if the value is `null`
2994
+ */
2995
+ get_null_member(member_name: string | null): boolean
2996
+ /**
2997
+ * Convenience function that retrieves the object
2998
+ * stored in `member_name` of `object`. It is an error to specify a `member_name`
2999
+ * which does not exist.
3000
+ *
3001
+ * If `member_name` contains `null`, then this function will return `NULL`.
3002
+ *
3003
+ * See also: [method`Json`.Object.get_member], [method`Json`.Object.has_member]
3004
+ * @param member_name the name of the member
3005
+ * @returns the object inside the object's member
3006
+ */
3007
+ get_object_member(member_name: string | null): Object | null
3008
+ /**
3009
+ * Retrieves the number of members of a JSON object.
3010
+ * @returns the number of members
3011
+ */
3012
+ get_size(): number
3013
+ /**
3014
+ * Convenience function that retrieves the string value
3015
+ * stored in `member_name` of `object`. It is an error to specify a
3016
+ * `member_name` that does not exist.
3017
+ *
3018
+ * See also: [method`Json`.Object.get_string_member_with_default],
3019
+ * [method`Json`.Object.get_member], [method`Json`.Object.has_member]
3020
+ * @param member_name the name of the member
3021
+ * @returns the string value of the object's member
3022
+ */
3023
+ get_string_member(member_name: string | null): string | null
3024
+ /**
3025
+ * Convenience function that retrieves the string value
3026
+ * stored in `member_name` of `object`.
3027
+ *
3028
+ * If `member_name` does not exist, does not contain a scalar value,
3029
+ * or contains `null`, then `default_value` is returned instead.
3030
+ * @param member_name the name of the `object` member
3031
+ * @param default_value the value to return if `member_name` is not valid
3032
+ * @returns the string value of the object's member, or the given default
3033
+ */
3034
+ get_string_member_with_default(member_name: string | null, default_value: string | null): string | null
3035
+ /**
3036
+ * Retrieves all the values of the members of an object.
3037
+ * @returns the member values of the object
3038
+ */
3039
+ get_values(): Node[] | null
3040
+ /**
3041
+ * Checks whether `object` has a member named `member_name`.
3042
+ * @param member_name the name of a JSON object member
3043
+ * @returns `TRUE` if the JSON object has the requested member
3044
+ */
3045
+ has_member(member_name: string | null): boolean
3046
+ /**
3047
+ * Calculate a hash value for the given `key` (a JSON object).
3048
+ *
3049
+ * The hash is calculated over the object and all its members, recursively. If
3050
+ * the object is immutable, this is a fast operation; otherwise, it scales
3051
+ * proportionally with the number of members in the object.
3052
+ * @returns hash value for @key
3053
+ */
3054
+ hash(): number
3055
+ /**
3056
+ * Checks whether the given object has been marked as immutable by calling
3057
+ * [method`Json`.Object.seal] on it.
3058
+ * @returns `TRUE` if the object is immutable
3059
+ */
3060
+ is_immutable(): boolean
3061
+ /**
3062
+ * Acquires a reference on the given object.
3063
+ * @returns the given object, with the reference count increased by one.
3064
+ */
3065
+ ref(): Object
3066
+ /**
3067
+ * Removes `member_name` from `object,` freeing its allocated resources.
3068
+ * @param member_name the name of the member to remove
3069
+ */
3070
+ remove_member(member_name: string | null): void
3071
+ /**
3072
+ * Seals the object, making it immutable to further changes.
3073
+ *
3074
+ * This function will recursively seal all members of the object too.
3075
+ *
3076
+ * If the object is already immutable, this is a no-op.
3077
+ */
3078
+ seal(): void
3079
+ /**
3080
+ * Convenience function for setting an object member with an array value.
3081
+ *
3082
+ * See also: [method`Json`.Object.set_member], [method`Json`.Node.take_array]
3083
+ * @param member_name the name of the member
3084
+ * @param value the value of the member
3085
+ */
3086
+ set_array_member(member_name: string | null, value: Array): void
3087
+ /**
3088
+ * Convenience function for setting an object member with a boolean value.
3089
+ *
3090
+ * See also: [method`Json`.Object.set_member], [method`Json`.Node.init_boolean]
3091
+ * @param member_name the name of the member
3092
+ * @param value the value of the member
3093
+ */
3094
+ set_boolean_member(member_name: string | null, value: boolean): void
3095
+ /**
3096
+ * Convenience function for setting an object member with a floating point value.
3097
+ *
3098
+ * See also: [method`Json`.Object.set_member], [method`Json`.Node.init_double]
3099
+ * @param member_name the name of the member
3100
+ * @param value the value of the member
3101
+ */
3102
+ set_double_member(member_name: string | null, value: number): void
3103
+ /**
3104
+ * Convenience function for setting an object member with an integer value.
3105
+ *
3106
+ * See also: [method`Json`.Object.set_member], [method`Json`.Node.init_int]
3107
+ * @param member_name the name of the member
3108
+ * @param value the value of the member
3109
+ */
3110
+ set_int_member(member_name: string | null, value: number): void
3111
+ /**
3112
+ * Sets the value of a member inside an object.
3113
+ *
3114
+ * If the object does not have a member with the given name, a new member
3115
+ * is created.
3116
+ *
3117
+ * If the object already has a member with the given name, the current
3118
+ * value is overwritten with the new.
3119
+ * @param member_name the name of the member
3120
+ * @param node the value of the member
3121
+ */
3122
+ set_member(member_name: string | null, node: Node): void
3123
+ /**
3124
+ * Convenience function for setting an object member with a `null` value.
3125
+ *
3126
+ * See also: [method`Json`.Object.set_member], [method`Json`.Node.init_null]
3127
+ * @param member_name the name of the member
3128
+ */
3129
+ set_null_member(member_name: string | null): void
3130
+ /**
3131
+ * Convenience function for setting an object member with an object value.
3132
+ *
3133
+ * See also: [method`Json`.Object.set_member], [method`Json`.Node.take_object]
3134
+ * @param member_name the name of the member
3135
+ * @param value the value of the member
3136
+ */
3137
+ set_object_member(member_name: string | null, value: Object): void
3138
+ /**
3139
+ * Convenience function for setting an object member with a string value.
3140
+ *
3141
+ * See also: [method`Json`.Object.set_member], [method`Json`.Node.init_string]
3142
+ * @param member_name the name of the member
3143
+ * @param value the value of the member
3144
+ */
3145
+ set_string_member(member_name: string | null, value: string | null): void
3146
+ /**
3147
+ * Releases a reference on the given object.
3148
+ *
3149
+ * If the reference count reaches zero, the object is destroyed and
3150
+ * all its resources are freed.
3151
+ */
3152
+ unref(): void
3153
+ }
3154
+
3155
+ /**
3156
+ * `JsonObject` is the representation of the object type inside JSON.
3157
+ *
3158
+ * A `JsonObject` contains [struct`Json`.Node] "members", which may contain
3159
+ * fundamental types, arrays or other objects; each member of an object is
3160
+ * accessed using a unique string, or "name".
3161
+ *
3162
+ * Since objects can be arbitrarily big, copying them can be expensive; for
3163
+ * this reason they are reference counted. You can control the lifetime of
3164
+ * a `JsonObject` using [method`Json`.Object.ref] and [method`Json`.Object.unref].
3165
+ *
3166
+ * To add or overwrite a member with a given name, use [method`Json`.Object.set_member].
3167
+ *
3168
+ * To extract a member with a given name, use [method`Json`.Object.get_member].
3169
+ *
3170
+ * To retrieve the list of members, use [method`Json`.Object.get_members].
3171
+ *
3172
+ * To retrieve the size of the object (that is, the number of members it has),
3173
+ * use [method`Json`.Object.get_size].
3174
+ * @record
3175
+ */
3176
+ class Object {
3177
+
3178
+ // Own properties of Json-1.0.Json.Object
3179
+
3180
+ static name: string
3181
+
3182
+ // Constructors of Json-1.0.Json.Object
3183
+
3184
+ /**
3185
+ * Creates a new object.
3186
+ * @constructor
3187
+ * @returns the newly created object
3188
+ */
3189
+ constructor()
3190
+ /**
3191
+ * Creates a new object.
3192
+ * @constructor
3193
+ * @returns the newly created object
3194
+ */
3195
+ static new(): Object
3196
+ }
3197
+
3198
+ interface ObjectIter {
3199
+
3200
+ // Owm methods of Json-1.0.Json.ObjectIter
3201
+
3202
+ /**
3203
+ * Initialises the `iter` and associate it with `object`.
3204
+ *
3205
+ * ```c
3206
+ * JsonObjectIter iter;
3207
+ * const gchar *member_name;
3208
+ * JsonNode *member_node;
3209
+ *
3210
+ * json_object_iter_init (&iter, some_object);
3211
+ * while (json_object_iter_next (&iter, &member_name, &member_node))
3212
+ * {
3213
+ * // Do something with `member_name` and `member_node`.
3214
+ * }
3215
+ * ```
3216
+ *
3217
+ * The iterator initialized with this function will iterate the
3218
+ * members of the object in an undefined order.
3219
+ *
3220
+ * See also: [method`Json`.ObjectIter.init_ordered]
3221
+ * @param object the JSON object to iterate over
3222
+ */
3223
+ init(object: Object): void
3224
+ /**
3225
+ * Initialises the `iter` and associate it with `object`.
3226
+ *
3227
+ * ```c
3228
+ * JsonObjectIter iter;
3229
+ * const gchar *member_name;
3230
+ * JsonNode *member_node;
3231
+ *
3232
+ * json_object_iter_init_ordered (&iter, some_object);
3233
+ * while (json_object_iter_next_ordered (&iter, &member_name, &member_node))
3234
+ * {
3235
+ * // Do something with `member_name` and `member_node`.
3236
+ * }
3237
+ * ```
3238
+ *
3239
+ * See also: [method`Json`.ObjectIter.init]
3240
+ * @param object the JSON object to iterate over
3241
+ */
3242
+ init_ordered(object: Object): void
3243
+ /**
3244
+ * Advances the iterator and retrieves the next member in the object.
3245
+ *
3246
+ * If the end of the object is reached, `FALSE` is returned and `member_name`
3247
+ * and `member_node` are set to invalid values. After that point, the `iter`
3248
+ * is invalid.
3249
+ *
3250
+ * The order in which members are returned by the iterator is undefined. The
3251
+ * iterator is invalidated if the object is modified during iteration.
3252
+ *
3253
+ * You must use this function with an iterator initialized with
3254
+ * [method`Json`.ObjectIter.init]; using this function with an iterator
3255
+ * initialized with [method`Json`.ObjectIter.init_ordered] yields undefined
3256
+ * behavior.
3257
+ *
3258
+ * See also: [method`Json`.ObjectIter.next_ordered]
3259
+ * @returns `TRUE` if @member_name and @member_node are valid; `FALSE` if there are no more members
3260
+ */
3261
+ next(): [ /* returnType */ boolean, /* member_name */ string | null, /* member_node */ Node ]
3262
+ /**
3263
+ * Advances the iterator and retrieves the next member in the object.
3264
+ *
3265
+ * If the end of the object is reached, `FALSE` is returned and `member_name` and
3266
+ * `member_node` are set to invalid values. After that point, the `iter` is invalid.
3267
+ *
3268
+ * The order in which members are returned by the iterator is the same order in
3269
+ * which the members were added to the `JsonObject`. The iterator is invalidated
3270
+ * if its `JsonObject` is modified during iteration.
3271
+ *
3272
+ * You must use this function with an iterator initialized with
3273
+ * [method`Json`.ObjectIter.init_ordered]; using this function with an iterator
3274
+ * initialized with [method`Json`.ObjectIter.init] yields undefined behavior.
3275
+ *
3276
+ * See also: [method`Json`.ObjectIter.next]
3277
+ * @returns `TRUE `if @member_name and @member_node are valid; `FALSE` if the end of the object has been reached
3278
+ */
3279
+ next_ordered(): [ /* returnType */ boolean, /* member_name */ string | null, /* member_node */ Node ]
3280
+ }
3281
+
3282
+ /**
3283
+ * An iterator object used to iterate over the members of a JSON object.
3284
+ *
3285
+ * `JsonObjectIter` must be allocated on the stack and initialised using
3286
+ * [method`Json`.ObjectIter.init] or [method`Json`.ObjectIter.init_ordered].
3287
+ *
3288
+ * The iterator is invalidated if the object is modified during
3289
+ * iteration.
3290
+ *
3291
+ * All the fields in the `JsonObjectIter` structure are private and should
3292
+ * never be accessed directly.
3293
+ * @record
3294
+ */
3295
+ class ObjectIter {
3296
+
3297
+ // Own properties of Json-1.0.Json.ObjectIter
3298
+
3299
+ static name: string
3300
+ }
3301
+
3302
+ interface ParserClass {
3303
+
3304
+ // Own fields of Json-1.0.Json.ParserClass
3305
+
3306
+ parse_start: (parser: Parser) => void
3307
+ object_start: (parser: Parser) => void
3308
+ object_member: (parser: Parser, object: Object, member_name: string | null) => void
3309
+ object_end: (parser: Parser, object: Object) => void
3310
+ array_start: (parser: Parser) => void
3311
+ array_element: (parser: Parser, array: Array, index_: number) => void
3312
+ array_end: (parser: Parser, array: Array) => void
3313
+ parse_end: (parser: Parser) => void
3314
+ error: (parser: Parser, error: GLib.Error) => void
3315
+ }
3316
+
3317
+ /**
3318
+ * The class structure for the JsonParser type.
3319
+ * @record
3320
+ */
3321
+ abstract class ParserClass {
3322
+
3323
+ // Own properties of Json-1.0.Json.ParserClass
3324
+
3325
+ static name: string
3326
+ }
3327
+
3328
+ interface ParserPrivate {
3329
+ }
3330
+
3331
+ class ParserPrivate {
3332
+
3333
+ // Own properties of Json-1.0.Json.ParserPrivate
3334
+
3335
+ static name: string
3336
+ }
3337
+
3338
+ interface PathClass {
3339
+ }
3340
+
3341
+ abstract class PathClass {
3342
+
3343
+ // Own properties of Json-1.0.Json.PathClass
3344
+
3345
+ static name: string
3346
+ }
3347
+
3348
+ interface ReaderClass {
3349
+ }
3350
+
3351
+ abstract class ReaderClass {
3352
+
3353
+ // Own properties of Json-1.0.Json.ReaderClass
3354
+
3355
+ static name: string
3356
+ }
3357
+
3358
+ interface ReaderPrivate {
3359
+ }
3360
+
3361
+ class ReaderPrivate {
3362
+
3363
+ // Own properties of Json-1.0.Json.ReaderPrivate
3364
+
3365
+ static name: string
3366
+ }
3367
+
3368
+ interface SerializableIface {
3369
+
3370
+ // Own fields of Json-1.0.Json.SerializableIface
3371
+
3372
+ serialize_property: (serializable: Serializable, property_name: string | null, value: any, pspec: GObject.ParamSpec) => Node
3373
+ deserialize_property: (serializable: Serializable, property_name: string | null, pspec: GObject.ParamSpec, property_node: Node) => [ /* returnType */ boolean, /* value */ any ]
3374
+ find_property: (serializable: Serializable, name: string | null) => GObject.ParamSpec | null
3375
+ set_property: (serializable: Serializable, pspec: GObject.ParamSpec, value: any) => void
3376
+ get_property: (serializable: Serializable, pspec: GObject.ParamSpec) => /* value */ any
3377
+ }
3378
+
3379
+ /**
3380
+ * Interface that allows serializing and deserializing object instances
3381
+ * with properties storing complex data types.
3382
+ *
3383
+ * The [func`Json`.gobject_from_data] and [func`Json`.gobject_to_data]
3384
+ * functions will check if the passed object type implements this interface,
3385
+ * so it can also be used to override the default property serialization
3386
+ * sequence.
3387
+ * @record
3388
+ */
3389
+ abstract class SerializableIface {
3390
+
3391
+ // Own properties of Json-1.0.Json.SerializableIface
3392
+
3393
+ static name: string
3394
+ }
3395
+
3396
+ /**
3397
+ * Name of the imported GIR library
3398
+ * @see https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L188
3399
+ */
3400
+ const __name__: string
3401
+ /**
3402
+ * Version of the imported GIR library
3403
+ * @see https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L189
3404
+ */
3405
+ const __version__: string
3406
+ }
3407
+
3408
+ export default Json;
3409
+ // END