Netdev List
 help / color / mirror / Atom feed
From: Tobias Jungel <tobias.jungel@bisdn.de>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: netdev@vger.kernel.org
Subject: [iproute2 PATCH] bridge: Correct json output
Date: Fri, 07 Sep 2018 15:42:57 +0200	[thread overview]
Message-ID: <9fec5ff1d75fa72511606b8a6b810ccdccbcb074.camel@bisdn.de> (raw)

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 --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)

                 reply	other threads:[~2018-09-07 18:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9fec5ff1d75fa72511606b8a6b810ccdccbcb074.camel@bisdn.de \
    --to=tobias.jungel@bisdn.de \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox