From c99dee1867be2c6a66e8f3149dd749a92441b003 Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Sun, 9 Aug 2020 11:19:40 +0200 Subject: [PATCH] Added functions Json::node_new_array|object. --- src/json.c | 26 ++++++++++++++++++++++++++ src/json.h | 3 +++ 2 files changed, 29 insertions(+) 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); -- 2.49.0