jsoninfo: systemTime and timeSinceStartup can be first
authorFerry Huberts <ferry.huberts@pelagic.nl>
Wed, 22 Apr 2015 08:33:49 +0000 (10:33 +0200)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Wed, 22 Apr 2015 11:39:14 +0000 (13:39 +0200)
A comma is only added when needed.

Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/jsoninfo/src/olsrd_jsoninfo.c

index 6f942a4..c7bd917 100644 (file)
@@ -1207,6 +1207,11 @@ static void send_info(unsigned int send_what, int the_socket) {
   if (send_what & SIW_ALL) {
     abuf_json_mark_output(true, &abuf);
 
+    abuf_json_int(&abuf, "systemTime", time(NULL));
+    abuf_json_int(&abuf, "timeSinceStartup", now_times);
+    if (*uuid)
+      abuf_json_string(&abuf, "uuid", uuid);
+
     if (send_what & SIW_LINKS)
       ipc_print_links(&abuf);
     if (send_what & SIW_NEIGHBORS)
@@ -1228,14 +1233,6 @@ static void send_info(unsigned int send_what, int the_socket) {
     if (send_what & SIW_PLUGINS)
       ipc_print_plugins(&abuf);
 
-    /* output overarching meta data last so we can use abuf_json_* functions, they add a comma at the beginning */
-    if (send_what & SIW_ALL) {
-      abuf_json_int(&abuf, "systemTime", time(NULL));
-      abuf_json_int(&abuf, "timeSinceStartup", now_times);
-      if (*uuid)
-        abuf_json_string(&abuf, "uuid", uuid);
-    }
-
     abuf_json_mark_output(false, &abuf);
     abuf_puts(&abuf, "\n");
   } else if (send_what & SIW_OLSRD_CONF) {