From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tobias Jungel Subject: [iproute2 PATCH] bridge: Correct json output Date: Fri, 07 Sep 2018 15:42:57 +0200 Message-ID: <9fec5ff1d75fa72511606b8a6b810ccdccbcb074.camel@bisdn.de> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org To: Stephen Hemminger Return-path: Received: from mx.bisdn.de ([185.27.182.31]:46383 "EHLO mx.bisdn.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729129AbeIGSdy (ORCPT ); Fri, 7 Sep 2018 14:33:54 -0400 Sender: netdev-owner@vger.kernel.org List-ID: 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 --- 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)