Gjsify LogoGjsify Logo

JsonObject is the representation of the object type inside JSON.

A JsonObject contains [structJson.Node] "members", which may contain fundamental types, arrays or other objects; each member of an object is accessed using a unique string, or "name".

Since objects can be arbitrarily big, copying them can be expensive; for this reason they are reference counted. You can control the lifetime of a JsonObject using [methodJson.Object.ref] and [methodJson.Object.unref].

To add or overwrite a member with a given name, use [methodJson.Object.set_member].

To extract a member with a given name, use [methodJson.Object.get_member].

To retrieve the list of members, use [methodJson.Object.get_members].

To retrieve the size of the object (that is, the number of members it has), use [methodJson.Object.get_size].

record

Hierarchy

  • Object

Index

Constructors

Properties

name: string

Methods

  • add_member(member_name: string, node: Json.Node): void
  • Adds a new member for the given name and value into an object.

    This function will return if the object already contains a member with the same name.

    Parameters

    • member_name: string

      the name of the member

    • node: Json.Node

      the value of the member

    Returns void

  • dup_member(member_name: string): Json.Node
  • Retrieves a copy of the value of the given member inside an object.

    Parameters

    • member_name: string

      the name of the JSON object member to access

    Returns Json.Node

  • Check whether a and b are equal objects, meaning they have the same set of members, and the values of corresponding members are equal.

    Parameters

    Returns boolean

  • Iterates over all members of object and calls func on each one of them.

    It is safe to change the value of a member of the oobject from within the iterator function, but it is not safe to add or remove members from the object.

    The order in which the object members are iterated is the insertion order.

    Parameters

    Returns void

  • get_array_member(member_name: string): Json.Array
  • Convenience function that retrieves the array stored in member_name of object. It is an error to specify a member_name which does not exist.

    If member_name contains null, then this function will return NULL.

    See also: [methodJson.Object.get_member], [methodJson.Object.has_member]

    Parameters

    • member_name: string

      the name of the member

    Returns Json.Array

  • get_boolean_member(member_name: string): boolean
  • Convenience function that retrieves the boolean value stored in member_name of object. It is an error to specify a member_name which does not exist.

    See also: [methodJson.Object.get_boolean_member_with_default], [methodJson.Object.get_member], [methodJson.Object.has_member]

    Parameters

    • member_name: string

      the name of the member

    Returns boolean

  • get_boolean_member_with_default(member_name: string, default_value: boolean): boolean
  • Convenience function that retrieves the boolean value stored in member_name of object.

    If member_name does not exist, does not contain a scalar value, or contains null, then default_value is returned instead.

    Parameters

    • member_name: string

      the name of the object member

    • default_value: boolean

      the value to return if member_name is not valid

    Returns boolean

  • get_double_member(member_name: string): number
  • Convenience function that retrieves the floating point value stored in member_name of object. It is an error to specify a member_name which does not exist.

    See also: [methodJson.Object.get_double_member_with_default], [methodJson.Object.get_member], [methodJson.Object.has_member]

    Parameters

    • member_name: string

      the name of the member

    Returns number

  • get_double_member_with_default(member_name: string, default_value: number): number
  • Convenience function that retrieves the floating point value stored in member_name of object.

    If member_name does not exist, does not contain a scalar value, or contains null, then default_value is returned instead.

    Parameters

    • member_name: string

      the name of the object member

    • default_value: number

      the value to return if member_name is not valid

    Returns number

  • get_int_member(member_name: string): number
  • Convenience function that retrieves the integer value stored in member_name of object. It is an error to specify a member_name which does not exist.

    See also: [methodJson.Object.get_int_member_with_default], [methodJson.Object.get_member], [methodJson.Object.has_member]

    Parameters

    • member_name: string

      the name of the object member

    Returns number

  • get_int_member_with_default(member_name: string, default_value: number): number
  • Convenience function that retrieves the integer value stored in member_name of object.

    If member_name does not exist, does not contain a scalar value, or contains null, then default_value is returned instead.

    Parameters

    • member_name: string

      the name of the object member

    • default_value: number

      the value to return if member_name is not valid

    Returns number

  • get_member(member_name: string): Json.Node
  • Retrieves the value of the given member inside an object.

    Parameters

    • member_name: string

      the name of the JSON object member to access

    Returns Json.Node

  • get_members(): string[]
  • Retrieves all the names of the members of an object.

    You can obtain the value for each member by iterating the returned list and calling [methodJson.Object.get_member].

    Returns string[]

  • get_null_member(member_name: string): boolean
  • Convenience function that checks whether the value stored in member_name of object is null. It is an error to specify a member_name which does not exist.

    See also: [methodJson.Object.get_member], [methodJson.Object.has_member]

    Parameters

    • member_name: string

      the name of the member

    Returns boolean

  • get_object_member(member_name: string): Json.Object
  • Convenience function that retrieves the object stored in member_name of object. It is an error to specify a member_name which does not exist.

    If member_name contains null, then this function will return NULL.

    See also: [methodJson.Object.get_member], [methodJson.Object.has_member]

    Parameters

    • member_name: string

      the name of the member

    Returns Json.Object

  • get_size(): number
  • get_string_member(member_name: string): string
  • Convenience function that retrieves the string value stored in member_name of object. It is an error to specify a member_name that does not exist.

    See also: [methodJson.Object.get_string_member_with_default], [methodJson.Object.get_member], [methodJson.Object.has_member]

    Parameters

    • member_name: string

      the name of the member

    Returns string

  • get_string_member_with_default(member_name: string, default_value: string): string
  • Convenience function that retrieves the string value stored in member_name of object.

    If member_name does not exist, does not contain a scalar value, or contains null, then default_value is returned instead.

    Parameters

    • member_name: string

      the name of the object member

    • default_value: string

      the value to return if member_name is not valid

    Returns string

  • has_member(member_name: string): boolean
  • Checks whether object has a member named member_name.

    Parameters

    • member_name: string

      the name of a JSON object member

    Returns boolean

  • hash(): number
  • Calculate a hash value for the given key (a JSON object).

    The hash is calculated over the object and all its members, recursively. If the object is immutable, this is a fast operation; otherwise, it scales proportionally with the number of members in the object.

    Returns number

  • is_immutable(): boolean
  • Checks whether the given object has been marked as immutable by calling [methodJson.Object.seal] on it.

    Returns boolean

  • remove_member(member_name: string): void
  • Removes member_name from object, freeing its allocated resources.

    Parameters

    • member_name: string

      the name of the member to remove

    Returns void

  • seal(): void
  • Seals the object, making it immutable to further changes.

    This function will recursively seal all members of the object too.

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

    Returns void

  • set_array_member(member_name: string, value: Json.Array): void
  • Convenience function for setting an object member with an array value.

    See also: [methodJson.Object.set_member], [methodJson.Node.take_array]

    Parameters

    • member_name: string

      the name of the member

    • value: Json.Array

      the value of the member

    Returns void

  • set_boolean_member(member_name: string, value: boolean): void
  • Convenience function for setting an object member with a boolean value.

    See also: [methodJson.Object.set_member], [methodJson.Node.init_boolean]

    Parameters

    • member_name: string

      the name of the member

    • value: boolean

      the value of the member

    Returns void

  • set_double_member(member_name: string, value: number): void
  • Convenience function for setting an object member with a floating point value.

    See also: [methodJson.Object.set_member], [methodJson.Node.init_double]

    Parameters

    • member_name: string

      the name of the member

    • value: number

      the value of the member

    Returns void

  • set_int_member(member_name: string, value: number): void
  • Convenience function for setting an object member with an integer value.

    See also: [methodJson.Object.set_member], [methodJson.Node.init_int]

    Parameters

    • member_name: string

      the name of the member

    • value: number

      the value of the member

    Returns void

  • set_member(member_name: string, node: Json.Node): void
  • Sets the value of a member inside an object.

    If the object does not have a member with the given name, a new member is created.

    If the object already has a member with the given name, the current value is overwritten with the new.

    Parameters

    • member_name: string

      the name of the member

    • node: Json.Node

      the value of the member

    Returns void

  • set_null_member(member_name: string): void
  • Convenience function for setting an object member with a null value.

    See also: [methodJson.Object.set_member], [methodJson.Node.init_null]

    Parameters

    • member_name: string

      the name of the member

    Returns void

  • set_object_member(member_name: string, value: Json.Object): void
  • Convenience function for setting an object member with an object value.

    See also: [methodJson.Object.set_member], [methodJson.Node.take_object]

    Parameters

    • member_name: string

      the name of the member

    • value: Json.Object

      the value of the member

    Returns void

  • set_string_member(member_name: string, value: string): void
  • Convenience function for setting an object member with a string value.

    See also: [methodJson.Object.set_member], [methodJson.Node.init_string]

    Parameters

    • member_name: string

      the name of the member

    • value: string

      the value of the member

    Returns void

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

    If the reference count reaches zero, the object is destroyed and all its 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