Gjsify LogoGjsify Logo

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].

record

Hierarchy

  • Array

Index

Constructors

Properties

name: string

Methods

  • 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]

    Parameters

    Returns void

  • add_boolean_element(value: boolean): void
  • Conveniently adds the given boolean value into an array.

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

    Parameters

    • value: boolean

      the boolean value to add

    Returns void

  • add_double_element(value: number): void
  • Conveniently adds the given floating point value into an array.

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

    Parameters

    • value: number

      the floating point value to add

    Returns void

  • add_int_element(value: number): void
  • Conveniently adds the given integer value into an array.

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

    Parameters

    • value: number

      the integer value to add

    Returns void

  • add_null_element(): void
  • Conveniently adds a null element into an array

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

    Returns void

  • 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]

    Parameters

    Returns void

  • add_string_element(value: string): void
  • Conveniently adds the given string value into an array.

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

    Parameters

    • value: string

      the string value to add

    Returns void

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

    Parameters

    • index_: number

      the index of the element to retrieve

    Returns Json.Node

  • 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

    Parameters

    Returns boolean

  • 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.

    Parameters

    • func: ArrayForeach

      the function to be called on each element

    Returns void

  • get_array_element(index_: number): Json.Array
  • Conveniently retrieves the array at the given position inside an array.

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

    Parameters

    • index_: number

      the index of the element to retrieve

    Returns Json.Array

  • get_boolean_element(index_: number): boolean
  • 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]

    Parameters

    • index_: number

      the index of the element to retrieve

    Returns boolean

  • get_double_element(index_: number): number
  • 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]

    Parameters

    • index_: number

      the index of the element to retrieve

    Returns number

  • get_int_element(index_: number): number
  • 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]

    Parameters

    • index_: number

      the index of the element to retrieve

    Returns number

  • get_length(): number
  • get_null_element(index_: number): boolean
  • 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]

    Parameters

    • index_: number

      the index of the element to retrieve

    Returns boolean

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

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

    Parameters

    • index_: number

      the index of the element to retrieve

    Returns Json.Object

  • get_string_element(index_: number): string
  • 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]

    Parameters

    • index_: number

      the index of the element to retrieve

    Returns string

  • hash(): number
  • 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.

    Returns number

  • is_immutable(): boolean
  • Check whether the given array has been marked as immutable by calling [methodJson.Array.seal] on it.

    Returns boolean

  • remove_element(index_: number): void
  • Removes the element at the given position inside an array.

    This function will release the reference held on the element.

    Parameters

    • index_: number

      the position of the element to be removed

    Returns void

  • seal(): void
  • 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.

    Returns void

  • unref(): void
  • Releases a reference on the given array.

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

    Returns void

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method