Skip to contentSkip to conversation

vis: Add an output format which is json conformant.

PATCH Applied Andrew Lunn 2 participants 2 messages Oct 7, 2013 – Oct 13, 2013

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 vis: Add an output format which is json conformant.

The current json output consists of individual lines which are json conformant, but there is no conformancy between lines. Add a new output format, which as a whole is json conformant.

---

Since v1:
Add routing algorithm to output
Add batadv-vis version to output
Update man page

Since v2:
Change cjson to jasondoc, as suggested by Nicolás Echániz

 README               |  44 +++++++-
 vis/man/batadv-vis.8 |  45 +++++++-
 vis/vis.c            | 302 ++++++++++++++++++++++++++++++++++++++++++---------
 vis/vis.h            |   3 +-
 4 files changed, 337 insertions(+), 57 deletions(-)
README +43 -1
index 50c36ad..83cdaf8 100644
@@ -152,7 +152,7 @@ digraph {
 [...]
 }
 
-For a json formatted output, use:
+For a json line formatted output, use:
 
  $ batadv-vis -f json
 { "primary" : "fe:f0:00:00:04:01" }
@@ -169,6 +169,48 @@ For a json formatted output, use:
 { "primary" : "fe:f0:00:00:08:01" }
 [...]
 
+and for output where the complete document is json, use:
+
+ $ batadv-vis -f jsondoc
+{
+  "source_version" : "2013.3.0-14-gcd34783",
+  "algorithm" : 4,
+  "vis" : [
+    { "primary" : "fe:f0:00:00:04:01",
+      "neighbors" : [
+         { "router" : "fe:f0:00:00:04:01",
+           "neighbor" : "fe:f0:00:00:05:01",
+           "metric" : "1.000" },
+         { "router" : "fe:f0:00:00:04:01",
+           "neighbor" : "fe:f0:00:00:03:01",
+           "metric" : "1.008" }
+      ],
+      "clients" : [
+         "00:00:43:05:00:04",
+         "fe:f1:00:00:04:01"
+      ]
+    },
+    { "primary" : "fe:f0:00:00:02:01",
+      "neighbors" : [
+         { "router" : "fe:f0:00:00:02:01",
+           "neighbor" : "fe:f0:00:00:03:01",
+  	 "metric" : "1.000" },
+         { "router" : "fe:f0:00:00:02:01",
+           "neighbor" : "fe:f0:00:00:01:01",
+           "metric" : "1.016" },
+         { "router" : "fe:f0:00:00:02:01",
+           "neighbor" : "fe:f0:00:00:08:01",
+           "metric" : "1.000" }
+      ],
+      "clients" : [
+        "fe:f1:00:00:02:01",
+        "00:00:43:05:00:02"
+      ]
+    },
+    { "primary" : "fe:f0:00:00:08:01",
+[...]
+
+
 License
 -------
 
vis/man/batadv-vis.8 +44 -1

57 lines not on this page · raw message

vis/vis.c +248 -54

345 lines not on this page · raw message

vis/vis.h +2 -1
index 6ba70c6..4ccbdad 100644
@@ -49,7 +49,8 @@ enum opmode {
 
 enum vis_format {
 	FORMAT_DOT,
-	FORMAT_JSON
+	FORMAT_JSON,
+	FORMAT_JSONDOC,
 };
 
 struct vis_iface {
Signature · 1 line
1.8.4.rc3
#1 lore raw
Quoted 5 lines · Andrew Lunn

The current json output consists of individual lines which are json conformant, but there is no conformancy between lines. Add a new output format, which as a whole is json conformant.

Applied in 38eae4d.

Thanks,
Simon