From 358c42a73ebc380d96e697664029aa4701df9699 Mon Sep 17 00:00:00 2001 From: Jan-Piet Mens Date: Tue, 16 Feb 2016 10:04:35 +0100 Subject: [PATCH] add CARD to single location in view --- http.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/http.c b/http.c index 0284092..167e441 100644 --- a/http.c +++ b/http.c @@ -397,6 +397,8 @@ static int send_status(struct mg_connection *conn, int status, char *text) * "disptst": "2015-09-18 20:59:59" * } * ] + * + * If `limit' then just one, and we add CARD details (face and name). */ static JsonNode *viewdata(struct mg_connection *conn, JsonNode *view, int limit) @@ -440,8 +442,26 @@ static JsonNode *viewdata(struct mg_connection *conn, JsonNode *view, int limit) locations(f->string_, obj, locs, s_lo, s_hi, JSON, limit, NULL, NULL, NULL); if (limit) { i_have += limit; - if (i_have >= limit) + if (i_have >= limit) { + JsonNode *o, *c = json_mkobject(); + append_card_to_object(c, ju->string_); + + /* Add card details to 0th locs element */ + if ((o = json_find_element(locs, 0)) != NULL) { + JsonNode *face, *name; + + face = json_find_member(c, "face"); + name = json_find_member(c, "name"); + + if (face) + json_append_member(o, "face", json_mkstring(face->string_)); + if (name) + json_append_member(o, "name", json_mkstring(name->string_)); + // puts(json_stringify(o, " ")); + } + json_delete(c); break; + } } } }