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

  • addMember(memberName: 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

    • memberName: string

      the name of the member

    • node: Json.Node

      the value of the member

    Returns void

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

    Parameters

    • memberName: 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

  • getArrayMember(memberName: 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

    • memberName: string

      the name of the member

    Returns Json.Array

  • getBooleanMember(memberName: 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

    • memberName: string

      the name of the member

    Returns boolean

  • getBooleanMemberWithDefault(memberName: string, defaultValue: 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

    • memberName: string

      the name of the object member

    • defaultValue: boolean

      the value to return if member_name is not valid

    Returns boolean

  • getDoubleMember(memberName: 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

    • memberName: string

      the name of the member

    Returns number

  • getDoubleMemberWithDefault(memberName: string, defaultValue: 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

    • memberName: string

      the name of the object member

    • defaultValue: number

      the value to return if member_name is not valid

    Returns number

  • getIntMember(memberName: 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

    • memberName: string

      the name of the object member

    Returns number

  • getIntMemberWithDefault(memberName: string, defaultValue: 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

    • memberName: string

      the name of the object member

    • defaultValue: number

      the value to return if member_name is not valid

    Returns number

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

    Parameters

    • memberName: string

      the name of the JSON object member to access

    Returns Json.Node

  • getMembers(): 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[]

  • getNullMember(memberName: 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

    • memberName: string

      the name of the member

    Returns boolean

  • 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

    • memberName: string

      the name of the member

    Returns Json.Object

  • getSize(): number
  • Retrieves the number of members of a JSON object.

    Returns number

  • getStringMember(memberName: 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

    • memberName: string

      the name of the member

    Returns string

  • getStringMemberWithDefault(memberName: string, defaultValue: 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

    • memberName: string

      the name of the object member

    • defaultValue: string

      the value to return if member_name is not valid

    Returns string

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

    Parameters

    • memberName: 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

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

    Returns boolean

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

    Parameters

    • memberName: 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

  • setArrayMember(memberName: 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

    • memberName: string

      the name of the member

    • value: Json.Array

      the value of the member

    Returns void

  • setBooleanMember(memberName: 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

    • memberName: string

      the name of the member

    • value: boolean

      the value of the member

    Returns void

  • setDoubleMember(memberName: 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

    • memberName: string

      the name of the member

    • value: number

      the value of the member

    Returns void

  • setIntMember(memberName: 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

    • memberName: string

      the name of the member

    • value: number

      the value of the member

    Returns void

  • setMember(memberName: 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

    • memberName: string

      the name of the member

    • node: Json.Node

      the value of the member

    Returns void

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

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

    Parameters

    • memberName: string

      the name of the member

    Returns void

  • setObjectMember(memberName: 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

    • memberName: string

      the name of the member

    • value: Json.Object

      the value of the member

    Returns void

  • setStringMember(memberName: 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

    • memberName: 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