Json.Serializable¶
- Implementations:
None
Methods¶
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
|
|
|
|
|
|
|
|
|
Properties¶
None
Signals¶
None
Fields¶
None
Class Details¶
- class Json.Serializable¶
- Bases:
- Structure:
JsonSerializable
is an interface for controlling the serialization and deserialization ofGObject
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 deserializevalue (
GObject.Value
) – a pointer to an uninitialized valuepspec (
GObject.ParamSpec
) – a property descriptionproperty_node (
Json.Node
) – the JSON node containing the serialized property
- Returns:
TRUE
if the property was successfully deserialized- Return type:
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 throughg_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 serializevalue (
GObject.Value
) – the value of the property to serializepspec (
GObject.ParamSpec
) – a property description
- Returns:
a node containing the serialized property
- Return type:
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 throughg_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 serializepspec (
GObject.ParamSpec
) – a property descriptionproperty_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 insideproperty_node
and place its value intovalue
.The
value
can be:an empty
GValue
initialized byG_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:
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:
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 serializevalue (
GObject.Value
) – the value of the property to serializepspec (
GObject.ParamSpec
) – a property description
- Returns:
a node containing the serialized property
- Return type:
Asks a
JsonSerializable
implementation to serialize an object property into a JSON node.
- set_property(pspec, value)¶
- Parameters:
pspec (
GObject.ParamSpec
) – a property descriptionvalue (
GObject.Value
) – the property value to set
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 serializepspec (
GObject.ParamSpec
) – a property descriptionproperty_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 insideproperty_node
and place its value intovalue
.The
value
can be:an empty
GValue
initialized byG_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:
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 serializevalue (
GObject.Value
) – the value of the property to serializepspec (
GObject.ParamSpec
) – a property description
- Returns:
a node containing the serialized property
- Return type:
Asks a
JsonSerializable
implementation to serialize an object property into a JSON node.
- do_set_property(pspec, value) virtual¶
- Parameters:
pspec (
GObject.ParamSpec
) – a property descriptionvalue (
GObject.Value
) – the property value to set
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.