Esempio n. 1
0
gboolean json_gobject_to_file(GObject * object, const gchar *filename)
{
	gchar *data;
	gsize length;
	data = json_gobject_to_data(object, &length);
	if (!data)
		return FALSE;

	GError *error = NULL;
	gboolean ret = g_file_set_contents(filename, data, length, &error);
	g_free(data);
	if (!ret)
		return FALSE;

	return ret;
}
Esempio n. 2
0
/**
 * json_serialize_gobject:
 * @gobject: a #GObject
 * @length: (out): return value for the length of the buffer, or %NULL
 *
 * Serializes a #GObject into a JSON data stream. If @gobject implements
 * the #JsonSerializableIface interface, it will be asked to serizalize all
 * its properties; otherwise, the default implementation will be use to
 * translate the compatible types into JSON native types.
 *
 * Return value: a JSON data stream representing the passed #GObject
 *
 * Deprecated: 0.10: Use json_gobject_to_data() instead
 */
gchar *
json_serialize_gobject (GObject *gobject,
                        gsize   *length)
{
  return json_gobject_to_data (gobject, length);
}