Gjsify LogoGjsify Logo

Index

Variables

MAJOR_VERSION: number

Json major version component (e.g. 1 if JSON_VERSION is "1.2.3")

MICRO_VERSION: number

Json micro version component (e.g. 3 if JSON_VERSION is "1.2.3")

MINOR_VERSION: number

Json minor version component (e.g. 2 if JSON_VERSION is "1.2.3")

VERSION_S: string

The version of JSON-GLib, encoded as a string, useful for printing and concatenation.

Functions

  • boxed_can_deserialize(gboxed_type: GType<unknown>, node_type: Json.NodeType): boolean
  • Checks whether it is possible to deserialize a GBoxed of type gboxed_type from a [structJson.Node] of type node_type.

    Parameters

    Returns boolean

  • Checks whether it is possible to serialize a GBoxed of type gboxed_type into a [structJson.Node].

    The type of the node is placed inside node_type if the function returns TRUE, and it's undefined otherwise.

    Parameters

    • gboxed_type: GType<unknown>

      a boxed type

    Returns [boolean, Json.NodeType]

  • boxed_deserialize(gboxed_type: GType<unknown>, node: Json.Node): object | null
  • Deserializes the given [structJson.Node] into a GBoxed of the given type.

    Parameters

    Returns object | null

  • boxed_serialize(gboxed_type: GType<unknown>, boxed: object): Json.Node | null
  • Serializes a pointer to a GBoxed of the given type into a [structJson.Node].

    If the serialization is not possible, this function will return NULL.

    Parameters

    • gboxed_type: GType<unknown>

      a boxed type

    • boxed: object

      a pointer to a boxed of type gboxed_type

    Returns Json.Node | null

  • construct_gobject(gtype: GType<unknown>, data: string, length: number): GObject.Object | null
  • Deserializes a JSON data stream and creates an instance of the given type

    If the given type implements the [ifaceJson.Serializable] interface, it will be asked to deserialize all the JSON members into their respective properties; otherwise, the default implementation will be used to translate the compatible JSON native types.

    Note: the JSON data stream must be an object.

    Parameters

    • gtype: GType<unknown>

      the type of the object to construct

    • data: string

      a JSON data stream

    • length: number

      length of the data stream

    Returns GObject.Object | null

  • from_string(str: string): Json.Node | null
  • Parses the given string and returns the corresponding JSON tree.

    If the string is empty, this function will return NULL.

    In case of parsing error, this function returns NULL and sets the error appropriately.

    Parameters

    • str: string

      a valid UTF-8 string containing JSON data

    Returns Json.Node | null

  • Creates a new GObject instance of the given type, and constructs it using the members of the object in the given node.

    Parameters

    • gtype: GType<unknown>

      the type of the object to create

    • node: Json.Node

      a node of type JSON_NODE_OBJECT describing the object instance for the given type

    Returns GObject.Object

  • gobject_from_data(gtype: GType<unknown>, data: string, length: number): GObject.Object | null
  • Deserializes a JSON data stream and creates an instance of the given type.

    If the type implements the [ifaceJson.Serializable] interface, it will be asked to deserialize all the JSON members into their respective properties; otherwise, the default implementation will be used to translate the compatible JSON native types.

    Note: the JSON data stream must be an object

    Parameters

    • gtype: GType<unknown>

      the type of the object to construct

    • data: string

      a JSON data stream

    • length: number

      length of the data stream, or -1 if it is NUL-terminated

    Returns GObject.Object | null

  • Creates a JSON tree representing the passed object instance.

    Each member of the returned JSON object will map to a property of the object type.

    The returned JSON tree will be returned as a JsonNode with a type of JSON_NODE_OBJECT.

    Parameters

    Returns Json.Node

  • Serializes a GObject instance into a JSON data stream, iterating recursively over each property.

    If the given object implements the [ifaceJson.Serializable] interface, it will be asked to serialize all its properties; otherwise, the default implementation will be use to translate the compatible types into JSON native types.

    Parameters

    Returns [string, number]

  • Converts a JSON data structure to a GVariant.

    If signature is not NULL, it will be used to resolve ambiguous data types.

    If no error occurs, the resulting GVariant is guaranteed to conform to signature.

    If signature is not NULL but does not represent a valid GVariant type string, NULL is returned and the error is set to G_IO_ERROR_INVALID_ARGUMENT.

    If a signature is provided but the JSON structure cannot be mapped to it, NULL is returned and the error is set to G_IO_ERROR_INVALID_DATA.

    If signature is NULL, the conversion is done based strictly on the types in the JSON nodes.

    The returned variant has a floating reference that will need to be sunk by the caller code.

    Parameters

    • json_node: Json.Node

      the node to convert

    • signature: string

      a valid GVariant type string

    Returns GLib.Variant | null

  • gvariant_deserialize_data(json: string, length: number, signature: string): GLib.Variant | null
  • Converts a JSON string to a GVariant value.

    This function works exactly like [funcJson.gvariant_deserialize], but takes a JSON encoded string instead.

    The string is first converted to a [structJson.Node] using [classJson.Parser], and then json_gvariant_deserialize is called on the node.

    The returned variant has a floating reference that will need to be sunk by the caller code.

    Parameters

    • json: string

      A JSON data string

    • length: number

      The length of json, or -1 if NUL-terminated

    • signature: string

      A valid GVariant type string

    Returns GLib.Variant | null

  • gvariant_serialize_data(variant: GLib.Variant): [string, number]
  • Converts variant to its JSON encoded string representation.

    This is a convenience function around [funcJson.gvariant_serialize], to obtain the JSON tree, and then [classJson.Generator] to stringify it.

    Parameters

    Returns [string, number]

  • parser_error_quark(): Quark
  • path_error_quark(): Quark
  • reader_error_quark(): Quark
  • Serializes a GObject instance into a JSON data stream.

    If the object implements the [ifaceJson.Serializable] interface, it will be asked to serizalize all its properties; otherwise, the default implementation will be use to translate the compatible types into JSON native types.

    Parameters

    Returns [string, number]

  • string_compare(a: string, b: string): number
  • Check whether a and b are equal UTF-8 JSON strings and return an ordering over them in strcmp() style.

    Parameters

    • a: string

      a JSON string

    • b: string

      another JSON string

    Returns number

  • string_equal(a: string, b: string): boolean
  • Check whether a and b are equal UTF-8 JSON strings.

    Parameters

    • a: string

      a JSON string

    • b: string

      another JSON string

    Returns boolean

  • string_hash(key: string): number
  • Calculate a hash value for the given key (a UTF-8 JSON string).

    Note: Member names are compared byte-wise, without applying any Unicode decomposition or normalisation. This is not explicitly mentioned in the JSON standard (ECMA-404), but is assumed.

    Parameters

    • key: string

      a JSON string to hash

    Returns number

  • to_string(node: Json.Node, pretty: boolean): string
  • Generates a stringified JSON representation of the contents of the given node.

    Parameters

    • node: Json.Node

      a JSON tree

    • pretty: boolean

      whether the output should be prettyfied for printing

    Returns string

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