Function

JsonBoxedSerializeFunc

Declaration

JsonNode*
BoxedSerializeFunc (
  gconstpointer boxed
)

Description [src]

Serializes the passed GBoxed and stores it inside a JsonNode, for instance:

static JsonNode *
my_point_serialize (gconstpointer boxed)
{
  const MyPoint *point = boxed;

  g_autoptr(JsonBuilder) builder = json_builder_new ();

  json_builder_begin_object (builder);
  json_builder_set_member_name (builder, "x");
  json_builder_add_double_value (builder, point->x);
  json_builder_set_member_name (builder, "y");
  json_builder_add_double_value (builder, point->y);
  json_builder_end_object (builder);

  return json_builder_get_root (builder);
}
Available since:0.10

Parameters

boxed gconstpointer
 

A boxed data structure.

Return value

Returns: JsonNode
 

The newly created JSON node tree representing the boxed data.

 The caller of the function takes ownership of the data, and is responsible for freeing it.