From: Donald Sharp Date: Fri, 17 Nov 2017 17:53:54 +0000 (-0500) Subject: bgpd: Fix json output in some situations X-Git-Tag: frr-4.0-dev~142^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=refs%2Fpull%2F1462%2Fhead;p=mirror%2Ffrr.git bgpd: Fix json output in some situations This commit fixes a bug where json output would display ',,,,,,,' because we were deciding to not display information about some routes due to a selection criteria. Signed-off-by: Donald Sharp --- diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index ba75da4591..a1c891fc66 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -8187,8 +8187,6 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, continue; display = 0; - if (!first && use_json) - vty_out(vty, ","); if (use_json) json_paths = json_object_new_array(); else @@ -8384,7 +8382,11 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, inet_ntop(p->family, &p->u.prefix, buf, BUFSIZ), p->prefixlen); - vty_out(vty, "\"%s\": ", buf2); + if (first) + vty_out(vty, "\"%s\": ", buf2); + else + vty_out(vty, ",\"%s\": ", buf2); + vty_out(vty, "%s", json_object_to_json_string_ext(json_paths, JSON_C_TO_STRING_PRETTY)); json_object_free(json_paths);