From: Andrea Zagli Date: Mon, 10 Aug 2020 14:07:04 +0000 (+0200) Subject: Added function ::get_stringify. X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=f3810d9243773b4432072980daa10f657d70a8c1;p=zakform%2Fjson Added function ::get_stringify. --- diff --git a/src/form.c b/src/form.c index f2fb3b5..19d80c8 100644 --- a/src/form.c +++ b/src/form.c @@ -256,6 +256,25 @@ const gchar return ret; } +const gchar +*zak_form_json_provider_get_stringify (ZakFormJsonProvider *provider) +{ + const gchar *ret; + + JsonGenerator *generator; + + ZakFormJsonProviderPrivate *priv = zak_form_json_provider_get_instance_private (provider); + + generator = json_generator_new (); + json_generator_set_root (generator, priv->root); + + ret = json_generator_to_data (generator, NULL); + + g_object_unref (generator); + + return ret; +} + /* PRIVATE */ static void zak_form_json_provider_set_property (GObject *object, diff --git a/src/form.h b/src/form.h index 5be56e6..4dfb1aa 100644 --- a/src/form.h +++ b/src/form.h @@ -38,6 +38,9 @@ ZakFormJsonProvider *zak_form_json_provider_new_from_data (const gchar *data, gs void zak_form_json_provider_set_filename (ZakFormJsonProvider *provider, const gchar *filename); const gchar *zak_form_json_provider_get_filename (ZakFormJsonProvider *provider); +const gchar *zak_form_json_provider_get_stringify (ZakFormJsonProvider *provider); + + G_END_DECLS