From 8e09dd305e599a87aea36f61c374ef2bcdc69398 Mon Sep 17 00:00:00 2001 From: Chip Black Date: Thu, 23 Dec 2010 04:51:06 -0600 Subject: [PATCH] Change JSON output format -- now an array of objects --- http_blerg.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/http_blerg.c b/http_blerg.c index d46313c..8c9aa51 100644 --- a/http_blerg.c +++ b/http_blerg.c @@ -98,17 +98,23 @@ ssize_t GET_generate_list(void *cls, uint64_t pos, char *buf, size_t max) { return -1; if (pos == 0) { /* Start iterating */ - yajl_gen_map_open(gs->g); + yajl_gen_array_open(gs->g); } /* Snarf one record */ blerg_fetch(gs->b, gs->entries[gs->i], &data, &len); + + yajl_gen_map_open(gs->g); + yajl_gen_string(gs->g, "record", 6); snprintf(number, 21, "%llu", gs->entries[gs->i]); yajl_gen_string(gs->g, number, strlen(number)); + yajl_gen_string(gs->g, "data", 4); yajl_gen_string(gs->g, data, len); + yajl_gen_map_close(gs->g); + free(data); if (gs->i == 0) { - yajl_gen_map_close(gs->g); + yajl_gen_array_close(gs->g); gs->done = 1; } gs->i--; -- 2.25.1