From 372516f77ac66e86663a61604bcdb776bcb6de9d Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 1 Aug 2021 16:23:32 +0200 Subject: 0 for absolute time is special, and should be treated as such in JSON generation --- src/json/json_pack.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/json') diff --git a/src/json/json_pack.c b/src/json/json_pack.c index c61d3331f..92f8b4535 100644 --- a/src/json/json_pack.c +++ b/src/json/json_pack.c @@ -248,12 +248,20 @@ struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_time_abs (const char *name, struct GNUNET_TIME_Absolute at) { - json_t *json; + struct GNUNET_JSON_PackSpec ps = { + .field_name = name + }; - json = GNUNET_JSON_from_time_abs (at); - GNUNET_assert (NULL != json); - return GNUNET_JSON_pack_object_steal (name, - json); + if (0 != at.abs_value_us) + { + ps.object = GNUNET_JSON_from_time_abs (at); + GNUNET_assert (NULL != ps.object); + } + else + { + ps.object = NULL; + } + return ps; } -- cgit v1.2.3