Json.Array¶
Fields¶
None
Methods¶
| class | new() | 
| class | sized_new(n_elements) | 
| add_array_element(value) | |
| add_boolean_element(value) | |
| add_double_element(value) | |
| add_element(node) | |
| add_int_element(value) | |
| add_null_element() | |
| add_object_element(value) | |
| add_string_element(value) | |
| dup_element(index_) | |
| equal(b) | |
| foreach_element(func, *data) | |
| get_array_element(index_) | |
| get_boolean_element(index_) | |
| get_double_element(index_) | |
| get_element(index_) | |
| get_elements() | |
| get_int_element(index_) | |
| get_length() | |
| get_null_element(index_) | |
| get_object_element(index_) | |
| get_string_element(index_) | |
| hash() | |
| is_immutable() | |
| ref() | |
| remove_element(index_) | |
| seal() | |
| unref() | 
Details¶
- 
class Json.Array¶
- A JSON array type. The contents of the - Json.Arraystructure are private and should only be accessed by the provided API- 
classmethod new()¶
- Returns: - the newly created - Json.Array- Return type: - Json.Array- Creates a new - Json.Array.
 - 
classmethod sized_new(n_elements)¶
- Parameters: - n_elements ( - int) – number of slots to pre-allocate- Returns: - the newly created - Json.Array- Return type: - Json.Array- Creates a new - Json.Arraywith n_elements slots already allocated.
 - 
add_array_element(value)¶
- Parameters: - value ( - Json.Arrayor- None) – a- Json.Array- Conveniently adds an array into self. The self takes ownership of the newly added - Json.Array- See also: - Json.Array.add_element(),- Json.Node.take_array()- New in version 0.8. 
 - 
add_boolean_element(value)¶
- Parameters: - value ( - bool) – a boolean value- Conveniently adds a boolean value into self - See also: - Json.Array.add_element(),- Json.Node.set_boolean()- New in version 0.8. 
 - 
add_double_element(value)¶
- Parameters: - value ( - float) – a floating point value- Conveniently adds a floating point value into self - See also: - Json.Array.add_element(),- Json.Node.set_double()- New in version 0.8. 
 - 
add_element(node)¶
- Parameters: - node ( - Json.Node) – a- Json.Node- Appends node inside self. The array will take ownership of the - Json.Node.
 - 
add_int_element(value)¶
- Parameters: - value ( - int) – an integer value- Conveniently adds an integer value into self - See also: - Json.Array.add_element(),- Json.Node.set_int()- New in version 0.8. 
 - 
add_null_element()¶
- Conveniently adds a null element into self - See also: - Json.Array.add_element(),- Json.NodeType.NULL- New in version 0.8. 
 - 
add_object_element(value)¶
- Parameters: - value ( - Json.Object) – a- Json.Object- Conveniently adds an object into self. The self takes ownership of the newly added - Json.Object- See also: - Json.Array.add_element(),- Json.Node.take_object()- New in version 0.8. 
 - 
add_string_element(value)¶
- Parameters: - value ( - str) – a string value- Conveniently adds a string value into self - See also: - Json.Array.add_element(),- Json.Node.set_string()- New in version 0.8. 
 - 
dup_element(index_)¶
- Parameters: - index ( - int) – the index of the element to retrieve- Returns: - a copy of the - Json.Nodeat the requested index. Use- Json.Node.unref() when done.- Return type: - Json.Node- Retrieves a copy of the - Json.Nodecontaining the value of the element at index_ inside a- Json.Array- New in version 0.6. 
 - 
equal(b)¶
- Parameters: - b ( - Json.Array) – another JSON array- Returns: - Trueif self and b are equal;- Falseotherwise- Return type: - bool- Check whether self and b are equal - Json.Arrays, meaning they have the same number of elements, and the values of elements in corresponding positions are equal.- New in version 1.2. 
 - 
foreach_element(func, *data)¶
- Parameters: - func (Json.ArrayForeach) – the function to be called on each element
- data (objectorNone) – data to be passed to the function
 - Iterates over all elements of self and calls func on each one of them. - It is safe to change the value of a - Json.Nodeof the self from within the iterator func, but it is not safe to add or remove elements from the self.- New in version 0.8. 
- func (
 - 
get_array_element(index_)¶
- Parameters: - index ( - int) – the index of the element to retrieve- Returns: - the array - Return type: - Json.Array- Conveniently retrieves the array from the element at index_ inside self - See also: - Json.Array.get_element(),- Json.Node.get_array()- New in version 0.8. 
 - 
get_boolean_element(index_)¶
- Parameters: - index ( - int) – the index of the element to retrieve- Returns: - the integer value - Return type: - bool- Conveniently retrieves the boolean value of the element at index_ inside self - See also: - Json.Array.get_element(),- Json.Node.get_boolean()- New in version 0.8. 
 - 
get_double_element(index_)¶
- Parameters: - index ( - int) – the index of the element to retrieve- Returns: - the floating point value - Return type: - float- Conveniently retrieves the floating point value of the element at index_ inside self - See also: - Json.Array.get_element(),- Json.Node.get_double()- New in version 0.8. 
 - 
get_element(index_)¶
- Parameters: - index ( - int) – the index of the element to retrieve- Returns: - a pointer to the - Json.Nodeat the requested index- Return type: - Json.Node- Retrieves the - Json.Nodecontaining the value of the element at index_ inside a- Json.Array.
 - 
get_elements()¶
- Returns: - a - GLib.Listcontaining the elements of the array. The contents of the list are owned by the array and should never be modified or freed. Use g_list_free() on the returned list when done using it- Return type: - [ - Json.Node]- Gets the elements of a - Json.Arrayas a list of- Json.Nodeinstances.
 - 
get_int_element(index_)¶
- Parameters: - index ( - int) – the index of the element to retrieve- Returns: - the integer value - Return type: - int- Conveniently retrieves the integer value of the element at index_ inside self - See also: - Json.Array.get_element(),- Json.Node.get_int()- New in version 0.8. 
 - 
get_length()¶
- Returns: - the length of the array - Return type: - int- Retrieves the length of a - Json.Array
 - 
get_null_element(index_)¶
- Parameters: - index ( - int) – the index of the element to retrieve- Returns: - Trueif the element is null- Return type: - bool- Conveniently retrieves whether the element at index_ is set to null - See also: - Json.Array.get_element(), JSON_NODE_TYPE(),- Json.NodeType.NULL- New in version 0.8. 
 - 
get_object_element(index_)¶
- Parameters: - index ( - int) – the index of the element to retrieve- Returns: - the object - Return type: - Json.Object- Conveniently retrieves the object from the element at index_ inside self - See also: - Json.Array.get_element(),- Json.Node.get_object()- New in version 0.8. 
 - 
get_string_element(index_)¶
- Parameters: - index ( - int) – the index of the element to retrieve- Returns: - the string value; the returned string is owned by the - Json.Arrayand should not be modified or freed- Return type: - str- Conveniently retrieves the string value of the element at index_ inside self - See also: - Json.Array.get_element(),- Json.Node.get_string()- New in version 0.8. 
 - 
hash()¶
- Returns: - hash value for self - Return type: - int- Calculate a hash value for the given self (a - Json.Array).- The hash is calculated over the array and all its elements, recursively. If the array is immutable, this is a fast operation; otherwise, it scales proportionally with the length of the array. - New in version 1.2. 
 - 
is_immutable()¶
- Returns: - Trueif the self is immutable- Return type: - bool- Check whether the given self has been marked as immutable by calling - Json.Array.seal() on it.- New in version 1.2. 
 - 
ref()¶
- Returns: - the passed - Json.Array, with the reference count increased by one.- Return type: - Json.Array- Increase by one the reference count of a - Json.Array.
 - 
remove_element(index_)¶
- Parameters: - index ( - int) – the position of the element to be removed- Removes the - Json.Nodeinside self at index_ freeing its allocated resources.
 - 
seal()¶
- Seals the - Json.Array, making it immutable to further changes. This will recursively seal all elements in the array too.- If the self is already immutable, this is a no-op. - New in version 1.2. 
 - 
unref()¶
- Decreases by one the reference count of a - Json.Array. If the reference count reaches zero, the array is destroyed and all its allocated resources are freed.
 
- 
classmethod