diff --git a/main.c b/main.c index 6559a8b..1f653d7 100644 --- a/main.c +++ b/main.c @@ -105,15 +105,21 @@ sendbooks(struct kreq *r) kjson_open(&req, r); kjson_obj_open(&req); if (NULL == b) { - kjson_putstringp(&req, "data", "error"); + kjson_objp_open(&req, "error"); + kjson_putstringp(&req, "msg", "Unknown book"); + kjson_obj_close(&req); } else { + kjson_objp_open(&req, "book"); kjson_putstringp(&req, "data", "books"); kjson_putintp(&req, "id", b->id); kjson_putstringp(&req, "title", b->title); + kjson_obj_close(&req); } +#ifdef __DEBUG__ kjson_putstringp(&req, "_path", r->path); kjson_putstringp(&req, "_pname", r->pname); kjson_putstringp(&req, "_pagename", r->pagename); +#endif kjson_obj_close(&req); kjson_close(&req); }