Json.Serializable

g GObject.GInterface GObject.GInterface Json.Serializable Json.Serializable GObject.GInterface->Json.Serializable

Implementations:

None

Methods

default_deserialize_property (property_name, value, pspec, property_node)

default_serialize_property (property_name, value, pspec)

deserialize_property (property_name, pspec, property_node)

find_property (name)

get_property (pspec)

list_properties ()

serialize_property (property_name, value, pspec)

set_property (pspec, value)

Virtual Methods

do_deserialize_property (property_name, pspec, property_node)

do_find_property (name)

do_get_property (pspec)

do_serialize_property (property_name, value, pspec)

do_set_property (pspec, value)

Properties

None

Signals

None

Fields

None

Class Details

class Json.Serializable
Bases:

GObject.GInterface

Structure:

Json.SerializableIface

JsonSerializable is an interface for controlling the serialization and deserialization of GObject classes.

Implementing this interface allows controlling how the class is going to be serialized or deserialized by [func`Json`.construct_gobject] and [func`Json`.serialize_gobject], respectively.

default_deserialize_property(property_name, value, pspec, property_node)
Parameters:
  • property_name (str) – the name of the property to deserialize

  • value (GObject.Value) – a pointer to an uninitialized value

  • pspec (GObject.ParamSpec) – a property description

  • property_node (Json.Node) – the JSON node containing the serialized property

Returns:

TRUE if the property was successfully deserialized

Return type:

bool

Calls the default implementation of the [vfunc`Json`.Serializable.deserialize_property] virtual function.

This function can be used inside a custom implementation of the deserialize_property() virtual function in lieu of calling the default implementation through g_type_default_interface_peek() :

```c Json.Serializable *iface; bool res;

iface = GObject.type_default_interface_peek (JSON_TYPE_SERIALIZABLE); res = iface->deserialize_property (serializable, property_name, value, pspec, property_node); ```

New in version 0.10.

default_serialize_property(property_name, value, pspec)
Parameters:
  • property_name (str) – the name of the property to serialize

  • value (GObject.Value) – the value of the property to serialize

  • pspec (GObject.ParamSpec) – a property description

Returns:

a node containing the serialized property

Return type:

Json.Node or None

Calls the default implementation of the [vfunc`Json`.Serializable.serialize_property] virtual function.

This function can be used inside a custom implementation of the serialize_property() virtual function in lieu of calling the default implementation through g_type_default_interface_peek() :

```c Json.Serializable *iface; Json.Node *node;

iface = GObject.type_default_interface_peek (JSON_TYPE_SERIALIZABLE); node = iface->serialize_property (serializable, property_name, value, pspec); ```

This function will return NULL if the property could not be serialized.

New in version 0.10.

deserialize_property(property_name, pspec, property_node)
Parameters:
  • property_name (str) – the name of the property to serialize

  • pspec (GObject.ParamSpec) – a property description

  • property_node (Json.Node) – the JSON node containing the serialized property

Returns:

TRUE if the property was successfully deserialized

value:

a pointer to an uninitialized value

Return type:

(bool, value: GObject.Value)

Asks a JsonSerializable implementation to deserialize the property contained inside property_node and place its value into value.

The value can be:

  • an empty GValue initialized by G_VALUE_INIT, which will be automatically initialized with the expected type of the property by using the given property description (since JSON-GLib 1.6)

  • a GValue initialized with the expected type of the property

This function will not be called for properties that are marked as as G_PARAM_CONSTRUCT_ONLY.

find_property(name)
Parameters:

name (str) – the name of the property

Returns:

the property description

Return type:

GObject.ParamSpec or None

Calls the [vfunc`Json`.Serializable.find_property] implementation on the JsonSerializable instance, which will return the property description for the given name.

New in version 0.14.

get_property(pspec)
Parameters:

pspec (GObject.ParamSpec) – a property description

Returns:

return location for the property value

Return type:

value: GObject.Value

Calls the [vfunc`Json`.Serializable.get_property] implementation on the JsonSerializable instance, which will get the value of the given property.

New in version 0.14.

list_properties()
Returns:

the serializable properties of the object

Return type:

[GObject.ParamSpec]

Calls the [vfunc`Json`.Serializable.list_properties] implementation on the JsonSerializable instance, which will return the list of serializable properties.

New in version 0.14.

serialize_property(property_name, value, pspec)
Parameters:
  • property_name (str) – the name of the property to serialize

  • value (GObject.Value) – the value of the property to serialize

  • pspec (GObject.ParamSpec) – a property description

Returns:

a node containing the serialized property

Return type:

Json.Node

Asks a JsonSerializable implementation to serialize an object property into a JSON node.

set_property(pspec, value)
Parameters:

Calls the [vfunc`Json`.Serializable.set_property] implementation on the JsonSerializable instance, which will set the property with the given value.

New in version 0.14.

do_deserialize_property(property_name, pspec, property_node) virtual
Parameters:
  • property_name (str) – the name of the property to serialize

  • pspec (GObject.ParamSpec) – a property description

  • property_node (Json.Node) – the JSON node containing the serialized property

Returns:

TRUE if the property was successfully deserialized

value:

a pointer to an uninitialized value

Return type:

(bool, value: GObject.Value)

Asks a JsonSerializable implementation to deserialize the property contained inside property_node and place its value into value.

The value can be:

  • an empty GValue initialized by G_VALUE_INIT, which will be automatically initialized with the expected type of the property by using the given property description (since JSON-GLib 1.6)

  • a GValue initialized with the expected type of the property

This function will not be called for properties that are marked as as G_PARAM_CONSTRUCT_ONLY.

do_find_property(name) virtual
Parameters:

name (str) – the name of the property

Returns:

the property description

Return type:

GObject.ParamSpec or None

Calls the [vfunc`Json`.Serializable.find_property] implementation on the JsonSerializable instance, which will return the property description for the given name.

New in version 0.14.

do_get_property(pspec) virtual
Parameters:

pspec (GObject.ParamSpec) – a property description

Returns:

return location for the property value

Return type:

value: GObject.Value

Calls the [vfunc`Json`.Serializable.get_property] implementation on the JsonSerializable instance, which will get the value of the given property.

New in version 0.14.

do_serialize_property(property_name, value, pspec) virtual
Parameters:
  • property_name (str) – the name of the property to serialize

  • value (GObject.Value) – the value of the property to serialize

  • pspec (GObject.ParamSpec) – a property description

Returns:

a node containing the serialized property

Return type:

Json.Node

Asks a JsonSerializable implementation to serialize an object property into a JSON node.

do_set_property(pspec, value) virtual
Parameters:

Calls the [vfunc`Json`.Serializable.set_property] implementation on the JsonSerializable instance, which will set the property with the given value.

New in version 0.14.