]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Fix 'show bgp ... summary json' to have empty {}
authorDonald Sharp <sharpd@cumulusnetworks.com>
Tue, 2 May 2017 14:20:10 +0000 (10:20 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 3 May 2017 02:34:21 +0000 (22:34 -0400)
When we have no output for a json command we should have
an empty {} displayed.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
bgpd/bgp_vty.c

index 361ab339624fff15774133c0d6001415b40fa391..a30721715c2c25904375fcce52090cb33dbd5013 100644 (file)
@@ -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