From cd3ad5506d188fdb7500d44e0e88a05c89ebf4f6 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Tue, 11 Feb 2014 09:25:52 +0100 Subject: [PATCH] store: Serialize attribute values using sdb_data_format(). --- src/core/store.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/core/store.c b/src/core/store.c index 7e26027..753b981 100644 --- a/src/core/store.c +++ b/src/core/store.c @@ -412,11 +412,13 @@ store_obj_tojson(sdb_llist_t *list, int type, sdb_strbuf_t *buf) time_str[sizeof(time_str) - 1] = '\0'; sdb_strbuf_append(buf, "{\"name\": \"%s\", ", SDB_OBJ(sobj)->name); - if (type == SDB_ATTRIBUTE) - /* XXX: this needs to be type-dependent */ - sdb_strbuf_append(buf, "\"value\": \"%s\", ", - SDB_ATTR(sobj)->value.data.string); - sdb_strbuf_append(buf, "\"last_update\": \"%s\"}", time_str); + if (type == SDB_ATTRIBUTE) { + sdb_strbuf_append(buf, "\"value\": "); + sdb_data_format(&SDB_ATTR(sobj)->value, buf); + sdb_strbuf_append(buf, ", \"last_update\": \"%s\"}", time_str); + } + else + sdb_strbuf_append(buf, "\"last_update\": \"%s\"}", time_str); if (sdb_llist_iter_has_next(iter)) sdb_strbuf_append(buf, ","); -- 2.30.2