Serializable Interface

## Serializable Interface Serializable Interface — Interface for serialize and deserialize special GObjects |

## Synopsis

                        JsonSerializableIface;
    JsonNode *          json_serializable_serialize_property
                                                            (JsonSerializable *serializable,
                                                             const gchar *property_name,
                                                             const GValue *value,
                                                             GParamSpec *pspec);
    gboolean            json_serializable_deserialize_property
                                                            (JsonSerializable *serializable,
                                                             const gchar *property_name,
                                                             GValue *value,
                                                             GParamSpec *pspec,
                                                             JsonNode *property_node);

    JsonNode *          json_serializable_default_serialize_property
                                                            (JsonSerializable *serializable,
                                                             const gchar *property_name,
                                                             const GValue *value,
                                                             GParamSpec *pspec);
    gboolean            json_serializable_default_deserialize_property
                                                            (JsonSerializable *serializable,
                                                             const gchar *property_name,
                                                             GValue *value,
                                                             GParamSpec *pspec,
                                                             JsonNode *property_node);

## Description

JsonSerializable is an interface for GObject classes that allows controlling how the class is going to be serialized or deserialized by `json_construct_gobject()` and `json_serialize_gobject()` respectively.

## Details

### JsonSerializableIface

    typedef struct {
      JsonNode *(* serialize_property)   (JsonSerializable *serializable,
                                          const gchar      *property_name,
                                          const GValue     *value,
                                          GParamSpec       *pspec);
      gboolean  (* deserialize_property) (JsonSerializable *serializable,
                                          const gchar      *property_name,
                                          GValue           *value,
                                          GParamSpec       *pspec,
                                          JsonNode         *property_node);
    } JsonSerializableIface;

Interface that allows serializing and deserializing GObjects with properties storing complex data types. The `json_serialize_gobject()` function will check if the passed GObject implements this interface, so it can also be used to override the default property serialization sequence.

`serialize_property` () | virtual function for serializing a GObject property into a JsonNode
`deserialize_property` () | virtual function for deserializing a JsonNode into a GObject property

### json_serializable_serialize_property ()

    JsonNode *          json_serializable_serialize_property
                                                            (JsonSerializable *serializable,
                                                             const gchar *property_name,
                                                             const GValue *value,
                                                             GParamSpec *pspec);

Asks a JsonSerializable implementation to serialize a GObject property into a JsonNode object.

`serializable` : | a JsonSerializable object
`property_name` : | the name of the property
`value` : | the value of the property
`pspec` : | a GParamSpec
Returns : | a JsonNode containing the serialized property

### json_serializable_deserialize_property ()

    gboolean            json_serializable_deserialize_property
                                                            (JsonSerializable *serializable,
                                                             const gchar *property_name,
                                                             GValue *value,
                                                             GParamSpec *pspec,
                                                             JsonNode *property_node);

Asks a JsonSerializable implementation to deserialize the property contained inside `property_node` into `value`.

`serializable` : | a JsonSerializable
`property_name` : | the name of the property
`value` : | a pointer to an uninitialized GValue
`pspec` : | a GParamSpec
`property_node` : | a JsonNode containing the serialized property
Returns : | `TRUE` if the property was successfully deserialized.

### json_serializable_default_serialize_property ()

    JsonNode *          json_serializable_default_serialize_property
                                                            (JsonSerializable *serializable,
                                                             const gchar *property_name,
                                                             const GValue *value,
                                                             GParamSpec *pspec);

Calls the default implementation of the JsonSerializable `serialize_property()` virtual function

This function can be used inside a custom implementation of the `serialize_property()` virtual function in lieu of:

      JsonSerializable *iface;
      JsonNode *node;

      iface = g_type_default_interface_peek (JSON_TYPE_SERIALIZABLE);
      node = iface->serialize_property (serializable, property_name,
                                        value,
                                        pspec);

`serializable` : | a JsonSerializable object
`property_name` : | the name of the property
`value` : | the value of the property
`pspec` : | a GParamSpec
Returns : | transfer full. transfer full.

Since 0.10

### json_serializable_default_deserialize_property ()

    gboolean            json_serializable_default_deserialize_property
                                                            (JsonSerializable *serializable,
                                                             const gchar *property_name,
                                                             GValue *value,
                                                             GParamSpec *pspec,
                                                             JsonNode *property_node);

Calls the default implementation of the JsonSerializable `deserialize_property()` virtual function

This function can be used inside a custom implementation of the `deserialize_property()` virtual function in lieu of:

      JsonSerializable *iface;
      gboolean res;

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

`serializable` : | a JsonSerializable
`property_name` : | the name of the property
`value` : | a pointer to an uninitialized GValue
`pspec` : | a GParamSpec
`property_node` : | a JsonNode containing the serialized property
Returns : | `TRUE` if the property was successfully deserialized.

Since 0.10