From: Andrea Zagli Date: Sun, 9 Aug 2020 09:20:01 +0000 (+0200) Subject: Use of libzakutilsjsonxml. X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=6ac588ebfabc6b329dbc481531ea0088a85ef68e;p=zakform%2Fjson Use of libzakutilsjsonxml. --- diff --git a/configure.ac b/configure.ac index d3111ac..d88ad6b 100644 --- a/configure.ac +++ b/configure.ac @@ -41,6 +41,7 @@ AM_GLIB_GNU_GETTEXT # Checks for libraries. PKG_CHECK_MODULES(ZAKFORMJSON, [libzakform libzakutils + libzakutilsjsonxml json-glib-1.0]) AC_SUBST(ZAKFORMJSON_CFLAGS) diff --git a/libzakformjson.pc.in b/libzakformjson.pc.in index b491991..a3cf6c1 100644 --- a/libzakformjson.pc.in +++ b/libzakformjson.pc.in @@ -7,6 +7,6 @@ modulesdir=@libdir@/@PACKAGE@/modules Name: @PACKAGE_NAME@ Description: Class for ZakFormIProvider based on json format. Version: @PACKAGE_VERSION@ -Requires: libzakform libzakutils json-glib-1.0 +Requires: libzakform libzakutils libzakutilsjsonxml json-glib-1.0 Libs: -L${libdir} -lzakformjson Cflags: -I${includedir} diff --git a/src/form.c b/src/form.c index cdea69c..f2fb3b5 100644 --- a/src/form.c +++ b/src/form.c @@ -24,6 +24,7 @@ #include #include +#include #include #include "form.h" @@ -158,13 +159,9 @@ ZakFormJsonProvider if (priv->root == NULL) { - JsonArray *jar; - g_warning ("Unable to get json root element."); - jar = json_array_new (); - priv->root = json_node_new (JSON_NODE_ARRAY); - json_node_init_array (priv->root, jar); + priv->root = zak_utils_json_node_new_array (); zak_form_json_provider_write_to_file (zak_form_json_provider); } @@ -208,13 +205,9 @@ ZakFormJsonProvider if (priv->root == NULL) { - JsonArray *jar; - g_warning ("Unable to get json root element."); - jar = json_array_new (); - priv->root = json_node_new (JSON_NODE_ARRAY); - json_node_init_array (priv->root, jar); + priv->root = zak_utils_json_node_new_array (); } return zak_form_json_provider; @@ -420,11 +413,10 @@ zak_form_json_provider_insert (ZakFormIProvider *provider, GPtrArray *elements) { JsonNode *jnode; - obj = json_object_new (); - - jnode = json_node_new (JSON_NODE_OBJECT); - json_node_init_object (jnode, obj); + jnode = zak_utils_json_node_new_object (); json_array_add_element (json_node_get_array (priv->root), jnode); + + obj = json_node_get_object (jnode); } for (i = 0; i < elements->len; i++)