From 9068d7fa1e1ce57ab55838866ac58b060721193e Mon Sep 17 00:00:00 2001 From: Miloslav Trmač Date: Fri, 24 Aug 2012 19:33:24 +0200 Subject: INCOMPATIBLE: Return {} for missing $!all-json MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit %$!all-json% will return a {}-wrapped object if there are are any events, or when there is an attached (empty) pMsg->event, but an empty string if nothing is attached. Let it return an empty object "{}" in that case for consistency. In particular, this allows $template MongoTemplate,"{%hostname:::jsonf:sys%, %$!all-json:2:$:%" to always result in a valid JSON. Signed-off-by: Miloslav Trmač --- runtime/msg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/msg.c b/runtime/msg.c index 61c2f87b..44d36fef 100644 --- a/runtime/msg.c +++ b/runtime/msg.c @@ -2734,7 +2734,7 @@ uchar *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe, if(pMsg->event == NULL) { if(*pbMustBeFreed == 1) free(pRes); - pRes = (uchar*) ""; + pRes = (uchar*) "{}"; *pbMustBeFreed = 0; } else { ee_fmtEventToJSON(pMsg->event, &str); -- cgit