batctl: Fix JSON object output

Message ID 1303569240-31956-1-git-send-email-sven@narfation.org (mailing list archive)
State Accepted, archived
Commit 3d7670d0745cd58108bc5516d0d5b525927c6cdf
Headers

Commit Message

Sven Eckelmann April 23, 2011, 2:34 p.m. UTC
  Each line is a single JSON object and has to start with '{' and no
spaces are allowed before it. Each pair has to be identified with a
string in double quotes.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 vis.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)
  

Comments

Marek Lindner April 25, 2011, 11:16 p.m. UTC | #1
On Saturday 23 April 2011 16:34:00 Sven Eckelmann wrote:
> Each line is a single JSON object and has to start with '{' and no
> spaces are allowed before it. Each pair has to be identified with a
> string in double quotes.

Applied in revision 81bc728.

Thanks,
Marek
  

Patch

diff --git a/vis.c b/vis.c
index eb77872..adb12d0 100644
--- a/vis.c
+++ b/vis.c
@@ -126,33 +126,33 @@  static void json_print_tq(char *orig, char *from, const long tq)
 	int int_part = TQ_MAX_VALUE / tq;
 	int frac_part = (1000 * TQ_MAX_VALUE / tq) - (int_part * 1000);
 
-	printf("\t{ router : \"%s\", ",
+	printf("{ \"router\" : \"%s\", ",
 	       get_name_by_macstr(orig, (with_names ? USE_BAT_HOSTS : 0)));
-	printf("neighbor : \"%s\", label : \"%d.%03d\" }\n",
+	printf("\"neighbor\" : \"%s\", \"label\" : \"%d.%03d\" }\n",
 	       get_name_by_macstr(from, (with_names ? USE_BAT_HOSTS : 0)),
 	       int_part, frac_part);
 }
 
 static void json_print_HNA(char *orig, char *from)
 {
-	printf("\t{ router : \"%s\", ",
+	printf("{ \"router\" : \"%s\", ",
 	       get_name_by_macstr(orig, (with_names ? USE_BAT_HOSTS : 0)));
-	printf("gateway : \"%s\", label : \"HNA\" }\n",
+	printf("\"gateway\" : \"%s\", \"label\" : \"HNA\" }\n",
 	       get_name_by_macstr(from, (with_names ? USE_BAT_HOSTS : 0)));
 }
 
 static void json_print_1st(char *orig)
 {
-	printf("\t{ primary : \"%s\" }\n",
+	printf("{ \"primary\" : \"%s\" }\n",
 	       get_name_by_macstr(orig, (with_names ? USE_BAT_HOSTS : 0)));
 }
 
 static void json_print_2nd(char *orig, char *from)
 {
-	printf("\t{ secondary : \"%s\", ",
+	printf("{ \"secondary\" : \"%s\", ",
 	       get_name_by_macstr(from, (with_names ? USE_BAT_HOSTS : 0)));
 
-	printf("of : \"%s\" }\n",
+	printf("\"of\" : \"%s\" }\n",
 	       get_name_by_macstr(orig, (with_names ? USE_BAT_HOSTS : 0)));
 }