From: Andrea Zagli Date: Tue, 21 Jul 2020 13:30:37 +0000 (+0200) Subject: Added functions Json::set_*. X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=3289f416489fd058b3aaaf56f12d6d05dbdb1aed;p=libzakutilsjsonxml Added functions Json::set_*. --- diff --git a/src/json.c b/src/json.c index 8968e62..3c0e380 100644 --- a/src/json.c +++ b/src/json.c @@ -69,3 +69,31 @@ zak_utils_json_get_boolean (JsonReader *reader, const gchar *name) return ret; } + +void +zak_utils_json_set_integer (JsonBuilder *builder, const gchar *name, gint value) +{ + json_builder_set_member_name (builder, name); + json_builder_add_int_value (builder, value); +} + +void +zak_utils_json_set_double (JsonBuilder *builder, const gchar *name, gdouble value) +{ + json_builder_set_member_name (builder, name); + json_builder_add_double_value (builder, value); +} + +void +zak_utils_json_set_string (JsonBuilder *builder, const gchar *name, const gchar *value) +{ + json_builder_set_member_name (builder, name); + json_builder_add_string_value (builder, value); +} + +void +zak_utils_json_set_boolean (JsonBuilder *builder, const gchar *name, gboolean value) +{ + json_builder_set_member_name (builder, name); + json_builder_add_boolean_value (builder, value); +} diff --git a/src/json.h b/src/json.h index 9fbe3b0..4aa1a1b 100644 --- a/src/json.h +++ b/src/json.h @@ -34,6 +34,11 @@ gdouble zak_utils_json_get_double (JsonReader *reader, const gchar *name); const gchar *zak_utils_json_get_string (JsonReader *reader, const gchar *name); gboolean zak_utils_json_get_boolean (JsonReader *reader, const gchar *name); +void zak_utils_json_set_integer (JsonBuilder *builder, const gchar *name, gint value); +void zak_utils_json_set_double (JsonBuilder *builder, const gchar *name, gdouble value); +void zak_utils_json_set_string (JsonBuilder *builder, const gchar *name, const gchar *value); +void zak_utils_json_set_boolean (JsonBuilder *builder, const gchar *name, gboolean value); + G_END_DECLS