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

  • addBooleanElement(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

  • addDoubleElement(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

  • addIntElement(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

  • addNullElement(): 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

  • addStringElement(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

  • 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

  • getBooleanElement(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

  • getDoubleElement(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

  • Retrieves the element at the given position in the array.

    Parameters

    • index: number

      the index of the element to retrieve

    Returns Json.Node

  • getIntElement(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

  • getLength(): number
  • getNullElement(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

  • getStringElement(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

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

    Returns boolean

  • removeElement(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

  • Creates a new array with n_elements slots already allocated.

    Parameters

    • nElements: number

      number of slots to pre-allocate

    Returns Json.Array

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