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