gi-json-1.0.2: JSON GObject bindings
CopyrightWill Thompson and Iñaki García Etxebarria
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellSafe-Inferred
LanguageHaskell2010

GI.Json.Structs.Array

Description

JsonArray is the representation of the array type inside JSON.

A JsonArray contains [structjson.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 [methodjson.Array.ref] and [methodjson.Array.unref].

To append an element, use [methodjson.Array.add_element].

To extract an element at a given index, use [methodjson.Array.get_element].

To retrieve the entire array in list form, use [methodjson.Array.get_elements].

To retrieve the length of the array, use [methodjson.Array.get_length].

Synopsis

Exported types

newtype Array Source #

Memory-managed wrapper type.

Constructors

Array (ManagedPtr Array) 

Instances

Instances details
Eq Array Source # 
Instance details

Defined in GI.Json.Structs.Array

Methods

(==) :: Array -> Array -> Bool #

(/=) :: Array -> Array -> Bool #

GBoxed Array Source # 
Instance details

Defined in GI.Json.Structs.Array

ManagedPtrNewtype Array Source # 
Instance details

Defined in GI.Json.Structs.Array

TypedObject Array Source # 
Instance details

Defined in GI.Json.Structs.Array

Methods

glibType :: IO GType #

HasParentTypes Array Source # 
Instance details

Defined in GI.Json.Structs.Array

IsGValue (Maybe Array) Source #

Convert Array to and from GValue. See toGValue and fromGValue.

Instance details

Defined in GI.Json.Structs.Array

type ParentTypes Array Source # 
Instance details

Defined in GI.Json.Structs.Array

type ParentTypes Array = '[] :: [Type]

Methods

addArrayElement

arrayAddArrayElement Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Array

array: a JSON array

-> Maybe Array

value: the array to add

-> m () 

Conveniently adds an array element into an array.

If value is NULL, a null element will be added instead.

See also: [methodjson.Array.add_element], [methodjson.Node.take_array]

Since: 0.8

addBooleanElement

arrayAddBooleanElement Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Array

array: a JSON array

-> Bool

value: the boolean value to add

-> m () 

Conveniently adds the given boolean value into an array.

See also: [methodjson.Array.add_element], [methodjson.Node.set_boolean]

Since: 0.8

addDoubleElement

arrayAddDoubleElement Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Array

array: a JSON array

-> Double

value: the floating point value to add

-> m () 

Conveniently adds the given floating point value into an array.

See also: [methodjson.Array.add_element], [methodjson.Node.set_double]

Since: 0.8

addElement

arrayAddElement Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Array

array: a JSON array

-> Node

node: the element to add

-> m () 

Appends the given node inside an array.

addIntElement

arrayAddIntElement Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Array

array: a JSON array

-> Int64

value: the integer value to add

-> m () 

Conveniently adds the given integer value into an array.

See also: [methodjson.Array.add_element], [methodjson.Node.set_int]

Since: 0.8

addNullElement

arrayAddNullElement Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Array

array: a JSON array

-> m () 

Conveniently adds a null element into an array

See also: [methodjson.Array.add_element], JSON_NODE_NULL

Since: 0.8

addObjectElement

arrayAddObjectElement Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Array

array: a JSON array

-> Maybe Object

value: the object to add

-> m () 

Conveniently adds an object into an array.

If value is NULL, a null element will be added instead.

See also: [methodjson.Array.add_element], [methodjson.Node.take_object]

Since: 0.8

addStringElement

arrayAddStringElement Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Array

array: a JSON array

-> Text

value: the string value to add

-> m () 

Conveniently adds the given string value into an array.

See also: [methodjson.Array.add_element], [methodjson.Node.set_string]

Since: 0.8

dupElement

arrayDupElement Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Array

array: a JSON array

-> Word32

index_: the index of the element to retrieve

-> m Node

Returns: a copy of the element at the given position

Retrieves a copy of the element at the given position in the array.

Since: 0.6

equal

arrayEqual Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Array

a: a JSON array

-> Array

b: another JSON array

-> m Bool

Returns: TRUE if the arrays are equal, and FALSE otherwise

Check whether two arrays are equal.

Equality is defined as:

  • the array have the same number of elements
  • the values of elements in corresponding positions are equal

Since: 1.2

foreachElement

arrayForeachElement Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Array

array: a JSON array

-> ArrayForeach

func: the function to be called on each element

-> m () 

Iterates over all elements of an array, and calls a function on each one of them.

It is safe to change the value of an element of the array while iterating over it, but it is not safe to add or remove elements from the array.

Since: 0.8

getArrayElement

arrayGetArrayElement Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Array

array: a JSON array

-> Word32

index_: the index of the element to retrieve

-> m Array

Returns: the array

Conveniently retrieves the array at the given position inside an array.

See also: [methodjson.Array.get_element], [methodjson.Node.get_array]

Since: 0.8

getBooleanElement

arrayGetBooleanElement Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Array

array: a JSON array

-> Word32

index_: the index of the element to retrieve

-> m Bool

Returns: the boolean value

Conveniently retrieves the boolean value of the element at the given position inside an array.

See also: [methodjson.Array.get_element], [methodjson.Node.get_boolean]

Since: 0.8

getDoubleElement

arrayGetDoubleElement Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Array

array: a JSON array

-> Word32

index_: the index of the element to retrieve

-> m Double

Returns: the floating point value

Conveniently retrieves the floating point value of the element at the given position inside an array.

See also: [methodjson.Array.get_element], [methodjson.Node.get_double]

Since: 0.8

getElement

arrayGetElement Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Array

array: a JSON array

-> Word32

index_: the index of the element to retrieve

-> m Node

Returns: the element at the given position

Retrieves the element at the given position in the array.

getElements

arrayGetElements Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Array

array: a JSON array

-> m [Node]

Returns: the elements of the array

Retrieves all the elements of an array as a list of nodes.

getIntElement

arrayGetIntElement Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Array

array: a JSON array

-> Word32

index_: the index of the element to retrieve

-> m Int64

Returns: the integer value

Conveniently retrieves the integer value of the element at the given position inside an array.

See also: [methodjson.Array.get_element], [methodjson.Node.get_int]

Since: 0.8

getLength

arrayGetLength Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Array

array: a JSON array

-> m Word32

Returns: the length of the array

Retrieves the length of the given array

getNullElement

arrayGetNullElement Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Array

array: a JSON array

-> Word32

index_: the index of the element to retrieve

-> m Bool

Returns: TRUE if the element is null

Conveniently checks whether the element at the given position inside the array contains a null value.

See also: [methodjson.Array.get_element], [methodjson.Node.is_null]

Since: 0.8

getObjectElement

arrayGetObjectElement Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Array

array: a JSON array

-> Word32

index_: the index of the element to retrieve

-> m Object

Returns: the object

Conveniently retrieves the object at the given position inside an array.

See also: [methodjson.Array.get_element], [methodjson.Node.get_object]

Since: 0.8

getStringElement

arrayGetStringElement Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Array

array: a JSON array

-> Word32

index_: the index of the element to retrieve

-> m Text

Returns: the string value

Conveniently retrieves the string value of the element at the given position inside an array.

See also: [methodjson.Array.get_element], [methodjson.Node.get_string]

Since: 0.8

hash

arrayHash Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Array

key: a JSON array to hash

-> m Word32

Returns: hash value for the key

Calculates a hash value for the given key.

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.

Since: 1.2

isImmutable

arrayIsImmutable Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Array

array: a JSON array

-> m Bool

Returns: True if the array is immutable

Check whether the given array has been marked as immutable by calling [methodjson.Array.seal] on it.

Since: 1.2

new

arrayNew Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> m Array

Returns: the newly created array

Creates a new array.

ref

arrayRef Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Array

array: the array to reference

-> m Array

Returns: the passed array, with the reference count increased by one

Acquires a reference on the given array.

removeElement

arrayRemoveElement Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Array

array: a JSON array

-> Word32

index_: the position of the element to be removed

-> m () 

Removes the element at the given position inside an array.

This function will release the reference held on the element.

seal

arraySeal Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Array

array: the array to seal

-> m () 

Seals the given array, making it immutable to further changes.

This function will recursively seal all elements in the array too.

If the array is already immutable, this is a no-op.

Since: 1.2

sizedNew

arraySizedNew Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Word32

nElements: number of slots to pre-allocate

-> m Array

Returns: the newly created array

Creates a new array with n_elements slots already allocated.

unref

arrayUnref Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Array

array: the array to unreference

-> m () 

Releases a reference on the given array.

If the reference count reaches zero, the array is destroyed and all its allocated resources are freed.