X-Git-Url: https://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=src%2Flp_json.c;h=5d2d4cd85403231352c866aea6e7bb32e9a75c7e;hb=eb26e5d2404df23c3151a55a6d887abb421ef601;hp=76a97d652b18fc46640c33feab83417bbca4657e;hpb=12b0e2c57c55b4d3086ef920deda5400016339f2;p=ppastats.git diff --git a/src/lp_json.c b/src/lp_json.c index 76a97d6..5d2d4cd 100644 --- a/src/lp_json.c +++ b/src/lp_json.c @@ -48,16 +48,20 @@ static time_t json_to_time(json_object *json) return -1; } -static json_object *time_to_json(time_t t) +json_object *time_to_json(time_t t) { char *str; + json_object *j; str = time_to_ISO8601_time(&t); - if (str) - return json_object_new_string(str); - else + if (str) { + j = json_object_new_string(str); + free(str); + return j; + } else { return NULL; + } } static struct bpph *json_to_bpph(json_object *o) @@ -103,7 +107,7 @@ static struct bpph *json_to_bpph(json_object *o) static json_object *bpph_to_json(struct bpph *bpph) { - json_object *json; + json_object *json, *time; json = json_object_new_object(); @@ -133,8 +137,9 @@ static json_object *bpph_to_json(struct bpph *bpph) json_object_object_add (json, "status", json_object_new_string(bpph->status)); + time = time_to_json(bpph->date_created); json_object_object_add - (json, "date_created", time_to_json(bpph->date_created)); + (json, "date_created", time); return json; }