diff mbox series

[iproute2] bridge: Correct json output

Message ID 9fec5ff1d75fa72511606b8a6b810ccdccbcb074.camel@bisdn.de
State Superseded, archived
Delegated to: stephen hemminger
Headers show
Series [iproute2] bridge: Correct json output | expand

Commit Message

Tobias Jungel Sept. 7, 2018, 1:42 p.m. UTC
The current implementation adds configured vlans as "vlan": [ ... ] into
an array. This is malformed json and fails to be parsed. This patch
creates an object to include this key value pair.

Test with:

ip l a type bridge
./bridge/bridge -j vlan | jq

fixes c7c1a1ef5

Signed-off-by: Tobias Jungel <tobias.jungel@bisdn.de>
---
 bridge/vlan.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/bridge/vlan.c b/bridge/vlan.c
index 19a36b80..9376b985 100644
--- a/bridge/vlan.c
+++ b/bridge/vlan.c
@@ -632,6 +632,7 @@  void print_vlan_info(FILE *fp, struct rtattr *tb)
 	if (!is_json_context())
 		fprintf(fp, "%s", _SL_);
 
+	open_json_object(NULL);
 	open_json_array(PRINT_JSON, "vlan");
 
 	for (i = RTA_DATA(list); RTA_OK(i, rem); i = RTA_NEXT(i, rem)) {
@@ -659,6 +660,7 @@  void print_vlan_info(FILE *fp, struct rtattr *tb)
 	}
 
 	close_json_array(PRINT_ANY, "\n");
+	close_json_object();
 }
 
 int do_vlan(int argc, char **argv)