### Interface

# Json Serializable

#### Description [src]

    interface Json.Serializable : GObject.Object

`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 `json_construct_gobject()` and `json_serialize_gobject()`, respectively.

#### Prerequisite

In order to implement Serializable, your type must inherit from`GObject`.

#### Instance methods

###### json_serializable_default_deserialize_property

Calls the default implementation of the `Json.SerializableIface.deserialize_property` virtual function.

since: 0.10

###### json_serializable_default_serialize_property

Calls the default implementation of the `Json.SerializableIface.serialize_property` virtual function.

since: 0.10

###### json_serializable_deserialize_property

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

###### json_serializable_find_property

Calls the `Json.SerializableIface.find_property` implementation on the `JsonSerializable` instance, which will return the property description for the given name.

since: 0.14

###### json_serializable_get_property

Calls the `Json.SerializableIface.get_property` implementation on the `JsonSerializable` instance, which will get the value of the given property.

since: 0.14

###### json_serializable_list_properties

Calls the `Json.SerializableIface.list_properties` implementation on the `JsonSerializable` instance, which will return the list of serializable properties.

since: 0.14

###### json_serializable_serialize_property

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

###### json_serializable_set_property

Calls the `Json.SerializableIface.set_property` implementation on the `JsonSerializable` instance, which will set the property with the given value.

since: 0.14

#### Interface structure

    struct JsonSerializableIface {
      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
      );
      GParamSpec* (* find_property) (
        JsonSerializable* serializable,
        const char* name
      );
      GParamSpec** (* list_properties) (
        JsonSerializable* serializable,
        guint* n_pspecs
      );
      void (* set_property) (
        JsonSerializable* serializable,
        GParamSpec* pspec,
        const GValue* value
      );
      void (* get_property) (
        JsonSerializable* serializable,
        GParamSpec* pspec,
        GValue* value
      );

    }

Interface that allows serializing and deserializing object instances with properties storing complex data types.

The `json_gobject_from_data()` and `json_gobject_to_data()` functions will check if the passed object type implements this interface, so it can also be used to override the default property serialization sequence.

###### Interface members

`serialize_property` |
    JsonNode* (* serialize_property) (
        JsonSerializable* serializable,
        const gchar* property_name,
        const GValue* value,
        GParamSpec* pspec
      )
| Virtual function for serializing an object property into JSON.
`deserialize_property` |
    gboolean (* deserialize_property) (
        JsonSerializable* serializable,
        const gchar* property_name,
        GValue* value,
        GParamSpec* pspec,
        JsonNode* property_node
      )
| Virtual function for deserializing JSON into an object property.
`find_property` |
    GParamSpec* (* find_property) (
        JsonSerializable* serializable,
        const char* name
      )
| Virtual function for finding a property definition using its name.
`list_properties` |
    GParamSpec** (* list_properties) (
        JsonSerializable* serializable,
        guint* n_pspecs
      )
| Virtual function for listing the installed property definitions.
`set_property` |
    void (* set_property) (
        JsonSerializable* serializable,
        GParamSpec* pspec,
        const GValue* value
      )
| Virtual function for setting a property.
`get_property` |
    void (* get_property) (
        JsonSerializable* serializable,
        GParamSpec* pspec,
        GValue* value
      )
| Virtual function for getting a property.

#### Virtual methods

###### Json.Serializable.deserialize_property

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

###### Json.Serializable.find_property

Calls the `Json.SerializableIface.find_property` implementation on the `JsonSerializable` instance, which will return the property description for the given name.

since: 0.14

###### Json.Serializable.get_property

Calls the `Json.SerializableIface.get_property` implementation on the `JsonSerializable` instance, which will get the value of the given property.

since: 0.14

###### Json.Serializable.list_properties

Virtual function for listing the installed property definitions.

###### Json.Serializable.serialize_property

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

###### Json.Serializable.set_property

Calls the `Json.SerializableIface.set_property` implementation on the `JsonSerializable` instance, which will set the property with the given value.

since: 0.14