From: Andrea Zagli Date: Sun, 9 Aug 2020 09:19:40 +0000 (+0200) Subject: Added functions Json::node_new_array|object. X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=c99dee1867be2c6a66e8f3149dd749a92441b003;p=libzakutilsjsonxml Added functions Json::node_new_array|object. --- diff --git a/src/json.c b/src/json.c index aab1b3c..c681b78 100644 --- a/src/json.c +++ b/src/json.c @@ -22,6 +22,32 @@ #include "json.h" +JsonNode +*zak_utils_json_node_new_array () +{ + JsonArray *jar; + JsonNode *jnode; + + jar = json_array_new (); + jnode = json_node_new (JSON_NODE_ARRAY); + json_node_init_array (jnode, jar); + + return jnode; +} + +JsonNode +*zak_utils_json_node_new_object () +{ + JsonObject *obj; + JsonNode *jnode; + + obj = json_object_new (); + jnode = json_node_new (JSON_NODE_OBJECT); + json_node_init_object (jnode, obj); + + return jnode; +} + gint zak_utils_json_get_integer (JsonReader *reader, const gchar *name) { diff --git a/src/json.h b/src/json.h index bb33f3b..2c5cefa 100644 --- a/src/json.h +++ b/src/json.h @@ -31,6 +31,9 @@ G_BEGIN_DECLS +JsonNode *zak_utils_json_node_new_array (void); +JsonNode *zak_utils_json_node_new_object (void); + gint zak_utils_json_get_integer (JsonReader *reader, const gchar *name); gdouble zak_utils_json_get_double (JsonReader *reader, const gchar *name); const gchar *zak_utils_json_get_string (JsonReader *reader, const gchar *name);