From 5ce77b2b1e6a4ce110f86180da4371a21dadb56e Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 2 May 2017 10:20:10 -0400 Subject: [PATCH] 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 --- bgpd/bgp_vty.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 -- 2.39.5