From: Donald Sharp Date: Tue, 2 May 2017 14:20:10 +0000 (-0400) Subject: bgpd: Fix 'show bgp ... summary json' to have empty {} X-Git-Tag: reindent-master-before~202^2~3 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=5ce77b2b1e6a4ce110f86180da4371a21dadb56e;p=matthieu%2Ffrr.git bgpd: Fix 'show bgp ... summary json' to have empty {} When we have no output for a json command we should have an empty {} displayed. Signed-off-by: Donald Sharp --- diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 361ab33962..a30721715c 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -6759,6 +6759,7 @@ bgp_show_summary_afi_safi (struct vty *vty, struct bgp *bgp, int afi, int safi, int afi_wildcard = (afi == AFI_MAX); int safi_wildcard = (safi == SAFI_MAX); int is_wildcard = (afi_wildcard || safi_wildcard); + bool json_output = false; if (use_json && is_wildcard) vty_out (vty, "{%s", VTY_NEWLINE); @@ -6772,6 +6773,7 @@ bgp_show_summary_afi_safi (struct vty *vty, struct bgp *bgp, int afi, int safi, { if (bgp_show_summary_afi_safi_peer_exists (bgp, afi, safi)) { + json_output = true; if (is_wildcard) { /* @@ -6812,7 +6814,8 @@ bgp_show_summary_afi_safi (struct vty *vty, struct bgp *bgp, int afi, int safi, if (use_json && is_wildcard) vty_out (vty, "}%s", VTY_NEWLINE); - + else if (use_json && !json_output) + vty_out (vty, "{}%s", VTY_NEWLINE); } static void