Array
Object Hierarchy:
Json.Array
Json.Array
Json.Array
Description:
[ CCode ( ref_function = "json_array_ref" , type_id = "json_array_get_type ()" , unref_function = "json_array_unref" ) ] [ Compact ]public class Array
`JsonArray` is the representation of the array type inside JSON.
A `JsonArray` contains [struct@Json.Node] elements, which may contain fundamental types, other arrays or objects.
Since arrays can be arbitrarily big, copying them can be expensive; for this reason, they are reference counted. You can control the lifetime
of a `JsonArray` using [method@Json.Array.ref] and [method@Json.Array.unref].
To append an element, use [method@Json.Array.add_element].
To extract an element at a given index, use [method@Json.Array.get_element].
To retrieve the entire array in list form, use [method@Json.Array.get_elements].
To retrieve the length of the array, use [method@Json.Array.get_length].
Content:
Creation methods:
Methods:
public unowned Array @ref ()
Acquires a reference on the given array.
public void add_array_element (owned Array ? value)
Conveniently adds an array element into an array.
public void add_boolean_element (bool value)
Conveniently adds the given boolean value into an array.
public void add_double_element (double value)
Conveniently adds the given floating point value into an array.
public void add_element (owned Node node)
Appends the given `node` inside an array.
public void add_int_element (int64 value)
Conveniently adds the given integer value into an array.
public void add_null_element ()
Conveniently adds a `null` element into an array
public void add_object_element (owned Object ? value)
Conveniently adds an object into an array.
public void add_string_element (string value)
Conveniently adds the given string value into an array.
public Node dup_element (uint index_)
Retrieves a copy of the element at the given position in the array.
public bool equal (Array b)
Check whether two arrays are equal.
public void foreach_element (ArrayForeach func)
Iterates over all elements of an array, and calls a function on each one of
them.
public unowned Array get_array_element (uint index_)
Conveniently retrieves the array at the given position inside an array.
public bool get_boolean_element (uint index_)
Conveniently retrieves the boolean value of the element at the given
position inside an array.
public double get_double_element (uint index_)
Conveniently retrieves the floating point value of the element at the given
position inside an array.
public unowned Node get_element (uint index_)
Retrieves the element at the given position in the array.
public List <unowned Node >? get_elements ()
Retrieves all the elements of an array as a list of nodes.
public int64 get_int_element (uint index_)
Conveniently retrieves the integer value of the element at the given
position inside an array.
public uint get_length ()
Retrieves the length of the given array
public bool get_null_element (uint index_)
Conveniently checks whether the element at the given position inside the
array contains a `null` value.
public unowned Object get_object_element (uint index_)
Conveniently retrieves the object at the given position inside an array.
public unowned string get_string_element (uint index_)
Conveniently retrieves the string value of the element at the given position
inside an array.
public uint hash ()
Calculates a hash value for the given `key`.
public bool is_immutable ()
Check whether the given `array` has been marked as immutable by calling [
method@Json.
public void remove_element (uint index_)
Removes the element at the given position inside an array.
public void seal ()
Seals the given array, making it immutable to further changes.
public void unref ()
Releases a reference on the given array.