gi-json-1.0.2: JSON GObject bindings
CopyrightWill Thompson and Iñaki García Etxebarria
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellSafe-Inferred
LanguageHaskell2010

GI.Json.Interfaces.Serializable

Description

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 [funcjson.construct_gobject] and [funcjson.serialize_gobject], respectively.

Synopsis

Exported types

class (GObject o, IsDescendantOf Serializable o) => IsSerializable o Source #

Type class for types which can be safely cast to Serializable, for instance with toSerializable.

Instances

Instances details
(GObject o, IsDescendantOf Serializable o) => IsSerializable o Source # 
Instance details

Defined in GI.Json.Interfaces.Serializable

toSerializable :: (MonadIO m, IsSerializable o) => o -> m Serializable Source #

Cast to Serializable, for types for which this is known to be safe. For general casts, use castTo.

Methods

defaultDeserializeProperty

serializableDefaultDeserializeProperty Source #

Arguments

:: (HasCallStack, MonadIO m, IsSerializable a) 
=> a

serializable: a serializable object

-> Text

propertyName: the name of the property to deserialize

-> GValue

value: a pointer to an uninitialized value

-> GParamSpec

pspec: a property description

-> Node

propertyNode: the JSON node containing the serialized property

-> m Bool

Returns: TRUE if the property was successfully deserialized

Calls the default implementation of the [vfuncjson.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 JsonSerializable *iface; gboolean res;

iface = g_type_default_interface_peek (JSON_TYPE_SERIALIZABLE); res = iface->deserialize_property (serializable, property_name, value, pspec, property_node); @``

Since: 0.10

defaultSerializeProperty

serializableDefaultSerializeProperty Source #

Arguments

:: (HasCallStack, MonadIO m, IsSerializable a) 
=> a

serializable: a serializable object

-> Text

propertyName: the name of the property to serialize

-> GValue

value: the value of the property to serialize

-> GParamSpec

pspec: a property description

-> m (Maybe Node)

Returns: a node containing the serialized property

Calls the default implementation of the [vfuncjson.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 JsonSerializable *iface; JsonNode *node;

iface = g_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.

Since: 0.10

deserializeProperty

serializableDeserializeProperty Source #

Arguments

:: (HasCallStack, MonadIO m, IsSerializable a) 
=> a

serializable: a serializable object

-> Text

propertyName: the name of the property to serialize

-> GParamSpec

pspec: a property description

-> Node

propertyNode: the JSON node containing the serialized property

-> m (Bool, GValue)

Returns: TRUE if the property was successfully deserialized

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

findProperty

serializableFindProperty Source #

Arguments

:: (HasCallStack, MonadIO m, IsSerializable a) 
=> a

serializable: a serializable object

-> Text

name: the name of the property

-> m (Maybe GParamSpec)

Returns: the property description

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

Since: 0.14

getProperty

serializableGetProperty Source #

Arguments

:: (HasCallStack, MonadIO m, IsSerializable a) 
=> a

serializable: a serializable object

-> GParamSpec

pspec: a property description

-> m GValue 

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

Since: 0.14

serializeProperty

serializableSerializeProperty Source #

Arguments

:: (HasCallStack, MonadIO m, IsSerializable a) 
=> a

serializable: a serializable object

-> Text

propertyName: the name of the property to serialize

-> GValue

value: the value of the property to serialize

-> GParamSpec

pspec: a property description

-> m Node

Returns: a node containing the serialized property

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

setProperty

serializableSetProperty Source #

Arguments

:: (HasCallStack, MonadIO m, IsSerializable a) 
=> a

serializable: a serializable object

-> GParamSpec

pspec: a property description

-> GValue

value: the property value to set

-> m () 

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

Since: 0.14