From 8cc845631720964071375b7c121c0c084f9f5564 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 17 Nov 2017 12:53:54 -0500 Subject: [PATCH] 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 --- bgpd/bgp_route.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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); -- 2.39.5