]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd,pimd,isisd,nhrpd: Convert to vty_json() 10449/head
authorDonatas Abraitis <donatas.abraitis@gmail.com>
Mon, 31 Jan 2022 19:20:41 +0000 (21:20 +0200)
committerDonatas Abraitis <donatas.abraitis@gmail.com>
Mon, 31 Jan 2022 19:20:41 +0000 (21:20 +0200)
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
bgpd/bgp_route.c
isisd/isis_te.c
nhrpd/nhrp_vty.c
pimd/pim_cmd.c

index d3bf9b6f2c84401e3485de619f71632ff8c6a63c..570464d1b98834b5fdf9b61aab9c5fceccd14062 100644 (file)
@@ -11186,10 +11186,7 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
                                else
                                        vty_out(vty, ",\"%pFX\": ", dest_p);
                        }
-                       vty_out(vty, "%s",
-                               json_object_to_json_string_ext(
-                                       json_paths, JSON_C_TO_STRING_PRETTY));
-                       json_object_free(json_paths);
+                       vty_json(vty, json_paths);
                        json_paths = NULL;
                        first = 0;
                } else
@@ -12043,12 +12040,8 @@ DEFUN(show_ip_bgp_statistics_all, show_ip_bgp_statistics_all_cmd,
                bgp_table_stats(vty, bgp, afi, safi, json_afi_safi);
        }
 
-       if (uj) {
-               vty_out(vty, "%s",
-                       json_object_to_json_string_ext(
-                               json_all, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json_all);
-       }
+       if (uj)
+               vty_json(vty, json_all);
 
        return CMD_SUCCESS;
 }
@@ -12089,9 +12082,7 @@ DEFUN (show_ip_bgp_l2vpn_evpn_statistics,
                json = json_object_new_object();
                json_object_object_add(json, get_afi_safi_str(afi, safi, true),
                                       json_afi_safi);
-               vty_out(vty, "%s", json_object_to_json_string_ext(
-                                         json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
+               vty_json(vty, json);
        }
        return ret;
 }
@@ -12129,10 +12120,7 @@ DEFUN(show_ip_bgp_afi_safi_statistics, show_ip_bgp_afi_safi_statistics_cmd,
                json = json_object_new_object();
                json_object_object_add(json, get_afi_safi_str(afi, safi, true),
                                       json_afi_safi);
-               vty_out(vty, "%s",
-                       json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
+               vty_json(vty, json);
        }
        return ret;
 }
index 93be70036ed43f18fc24f00dfa8507f5a428d452..118bcf78000ada97eab15d17a484466655e63a75 100644 (file)
@@ -1687,12 +1687,8 @@ static int show_ted(struct vty *vty, struct cmd_token *argv[], int argc,
                ls_show_ted(ted, vty, json, detail);
        }
 
-       if (uj) {
-               vty_out(vty, "%s\n",
-                       json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       }
+       if (uj)
+               vty_json(vty, json);
 
        return CMD_SUCCESS;
 }
index 97290ca84f81c2dc9c2e74d470877abaa2ef7bbe..4db2d8b89e3b4c34e45ef19577179e641b55a894 100644 (file)
@@ -987,10 +987,7 @@ DEFUN(show_ip_nhrp, show_ip_nhrp_cmd,
        if (uj) {
                json_object_object_add(json_vrf_path, "attr", json_vrf);
                json_object_object_add(json_vrf_path, "table", ctx.json);
-               vty_out(vty, "%s",
-                       json_object_to_json_string_ext(
-                              json_vrf_path, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json_vrf_path);
+               vty_json(vty, json_vrf_path);
        }
        return ret;
 }
@@ -1052,12 +1049,8 @@ DEFUN(show_dmvpn, show_dmvpn_cmd,
                ctxt.json = json_path;
        }
        nhrp_vc_foreach(show_dmvpn_entry, &ctxt);
-       if (uj) {
-               vty_out(vty, "%s",
-                       json_object_to_json_string_ext(
-                              json_path, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json_path);
-       }
+       if (uj)
+               vty_json(vty, json_path);
        return CMD_SUCCESS;
 }
 
index e2ac77730442d96a86751028681a79280caaa492..01cb35177e7e920dbdab27fc502b9e77c33d6188 100644 (file)
@@ -564,11 +564,8 @@ static void igmp_show_interfaces(struct pim_instance *pim, struct vty *vty,
                }
        }
 
-       if (uj) {
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       }
+       if (uj)
+               vty_json(vty, json);
 }
 
 static void igmp_show_interfaces_single(struct pim_instance *pim,
@@ -789,14 +786,10 @@ static void igmp_show_interfaces_single(struct pim_instance *pim,
                }
        }
 
-       if (uj) {
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       } else {
-               if (!found_ifname)
-                       vty_out(vty, "%% No such interface\n");
-       }
+       if (uj)
+               vty_json(vty, json);
+       else if (!found_ifname)
+               vty_out(vty, "%% No such interface\n");
 }
 
 static void igmp_show_interface_join(struct pim_instance *pim, struct vty *vty,
@@ -890,11 +883,8 @@ static void igmp_show_interface_join(struct pim_instance *pim, struct vty *vty,
 
        } /* for (iflist) */
 
-       if (uj) {
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                                            json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       }
+       if (uj)
+               vty_json(vty, json);
 }
 
 static void pim_show_interfaces_single(struct pim_instance *pim,
@@ -1308,14 +1298,10 @@ static void pim_show_interfaces_single(struct pim_instance *pim,
                }
        }
 
-       if (uj) {
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       } else {
-               if (!found_ifname)
-                       vty_out(vty, "%% No such interface\n");
-       }
+       if (uj)
+               vty_json(vty, json);
+       else if (!found_ifname)
+               vty_out(vty, "%% No such interface\n");
 }
 
 static void igmp_show_statistics(struct pim_instance *pim, struct vty *vty,
@@ -1368,9 +1354,7 @@ static void igmp_show_statistics(struct pim_instance *pim, struct vty *vty,
                                    rx_stats.unsupported);
                json_object_object_add(json, ifname ? ifname : "global",
                                       json_row);
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
+               vty_json(vty, json);
        } else {
                vty_out(vty, "IGMP RX statistics\n");
                vty_out(vty, "Interface       : %s\n",
@@ -1566,11 +1550,8 @@ static void pim_show_interface_traffic(struct pim_instance *pim,
                                pim_ifp->pim_ifstat_bsm_tx);
                }
        }
-       if (uj) {
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       }
+       if (uj)
+               vty_json(vty, json);
 }
 
 static void pim_show_interface_traffic_single(struct pim_instance *pim,
@@ -1659,14 +1640,10 @@ static void pim_show_interface_traffic_single(struct pim_instance *pim,
                                pim_ifp->pim_ifstat_bsm_tx);
                }
        }
-       if (uj) {
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       } else {
-               if (!found_ifname)
-                       vty_out(vty, "%% No such interface\n");
-       }
+       if (uj)
+               vty_json(vty, json);
+       else if (!found_ifname)
+               vty_out(vty, "%% No such interface\n");
 }
 
 static void pim_show_join_helper(struct vty *vty, struct pim_interface *pim_ifp,
@@ -1772,11 +1749,8 @@ static void pim_show_join(struct pim_instance *pim, struct vty *vty,
                } /* scan interface channels */
        }
 
-       if (uj) {
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       }
+       if (uj)
+               vty_json(vty, json);
 }
 
 static void pim_show_neighbors_single(struct pim_instance *pim, struct vty *vty,
@@ -1975,17 +1949,10 @@ static void pim_show_neighbors_single(struct pim_instance *pim, struct vty *vty,
                }
        }
 
-       if (uj) {
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       } else {
-               {
-                       if (!found_neighbor)
-                               vty_out(vty,
-                                       "%% No such interface or neighbor\n");
-               }
-       }
+       if (uj)
+               vty_json(vty, json);
+       else if (!found_neighbor)
+               vty_out(vty, "%% No such interface or neighbor\n");
 }
 
 static void pim_show_state(struct pim_instance *pim, struct vty *vty,
@@ -2202,13 +2169,10 @@ static void pim_show_state(struct pim_instance *pim, struct vty *vty,
        }
 
 
-       if (uj) {
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       } else {
+       if (uj)
+               vty_json(vty, json);
+       else
                vty_out(vty, "\n");
-       }
 }
 
 static void pim_show_neighbors(struct pim_instance *pim, struct vty *vty,
@@ -2286,11 +2250,8 @@ static void pim_show_neighbors(struct pim_instance *pim, struct vty *vty,
                }
        }
 
-       if (uj) {
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       }
+       if (uj)
+               vty_json(vty, json);
 }
 
 static void pim_show_neighbors_secondary(struct pim_instance *pim,
@@ -2585,11 +2546,8 @@ static void pim_show_upstream(struct pim_instance *pim, struct vty *vty,
                }
        }
 
-       if (uj) {
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       }
+       if (uj)
+               vty_json(vty, json);
 }
 
 static void pim_show_channel_helper(struct pim_instance *pim,
@@ -2680,11 +2638,8 @@ static void pim_show_channel(struct pim_instance *pim, struct vty *vty,
                }
        }
 
-       if (uj) {
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       }
+       if (uj)
+               vty_json(vty, json);
 }
 
 static void pim_show_join_desired_helper(struct pim_instance *pim,
@@ -2746,11 +2701,8 @@ static void pim_show_join_desired(struct pim_instance *pim, struct vty *vty,
                                             json, uj);
        }
 
-       if (uj) {
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       }
+       if (uj)
+               vty_json(vty, json);
 }
 
 static void pim_show_upstream_rpf(struct pim_instance *pim, struct vty *vty,
@@ -2814,11 +2766,8 @@ static void pim_show_upstream_rpf(struct pim_instance *pim, struct vty *vty,
                }
        }
 
-       if (uj) {
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       }
+       if (uj)
+               vty_json(vty, json);
 }
 
 static void show_rpf_refresh_stats(struct vty *vty, struct pim_instance *pim,
@@ -2957,11 +2906,8 @@ static void pim_show_rpf(struct pim_instance *pim, struct vty *vty, bool uj)
                }
        }
 
-       if (uj) {
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       }
+       if (uj)
+               vty_json(vty, json);
 }
 
 struct pnc_cache_walk_data {
@@ -3158,11 +3104,8 @@ static void pim_show_bsm_db(struct pim_instance *pim, struct vty *vty, bool uj)
                fragment++;
        }
 
-       if (uj) {
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       }
+       if (uj)
+               vty_json(vty, json);
 }
 
 /*Display the group-rp mappings */
@@ -3290,11 +3233,8 @@ static void pim_show_group_rp_mappings_info(struct pim_instance *pim,
                        vty_out(vty, "\n");
        }
 
-       if (uj) {
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       }
+       if (uj)
+               vty_json(vty, json);
 }
 
 /* pim statistics - just adding only bsm related now.
@@ -3365,11 +3305,8 @@ static void pim_show_statistics(struct pim_instance *pim, struct vty *vty,
                vty_out(vty, "\n");
        }
 
-       if (uj) {
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       }
+       if (uj)
+               vty_json(vty, json);
 }
 
 static void clear_pim_statistics(struct pim_instance *pim)
@@ -3497,11 +3434,8 @@ static void igmp_show_groups(struct pim_instance *pim, struct vty *vty, bool uj)
                } /* scan igmp groups */
        }         /* scan interfaces */
 
-       if (uj) {
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       }
+       if (uj)
+               vty_json(vty, json);
 }
 
 static void igmp_show_group_retransmission(struct pim_instance *pim,
@@ -3725,11 +3659,8 @@ static void pim_show_bsr(struct pim_instance *pim,
                vty_out(vty, "Last BSM seen: %s\n", last_bsm_seen);
        }
 
-       if (uj) {
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       }
+       if (uj)
+               vty_json(vty, json);
 }
 
 static void clear_igmp_interfaces(struct pim_instance *pim)
@@ -4387,9 +4318,7 @@ DEFUN (show_ip_pim_mlag_summary,
                                    router->mlag_stats.msg.vxlan_updates);
                json_object_object_add(json, "connStats", json_stat);
 
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
+               vty_json(vty, json);
                return CMD_SUCCESS;
        }
 
@@ -4879,11 +4808,8 @@ static void pim_show_mlag_up_detail(struct vrf *vrf,
                                              src_str, grp_str, json);
        }
 
-       if (uj) {
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       }
+       if (uj)
+               vty_json(vty, json);
 }
 
 static void pim_show_mlag_up_vrf(struct vrf *vrf, struct vty *vty, bool uj)
@@ -4967,11 +4893,8 @@ static void pim_show_mlag_up_vrf(struct vrf *vrf, struct vty *vty, bool uj)
                                ? "n" : "y");
                }
        }
-       if (uj) {
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       }
+       if (uj)
+               vty_json(vty, json);
 }
 
 static void pim_show_mlag_help_string(struct vty *vty, bool uj)
@@ -5731,12 +5654,8 @@ static void show_multicast_interfaces(struct pim_instance *pim, struct vty *vty,
                }
        }
 
-       if (uj) {
-               vty_out(vty, "%s\n",
-                       json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       }
+       if (uj)
+               vty_json(vty, json);
 }
 
 static void pim_cmd_show_ip_multicast_helper(struct pim_instance *pim,
@@ -6255,11 +6174,8 @@ static void show_mroute(struct pim_instance *pim, struct vty *vty,
                }
        }
 
-       if (uj) {
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       }
+       if (uj)
+               vty_json(vty, json);
 }
 
 DEFPY (show_ip_mroute,
@@ -6451,12 +6367,8 @@ static void show_mroute_count(struct pim_instance *pim, struct vty *vty,
        for (ALL_LIST_ELEMENTS_RO(pim->static_routes, node, sr))
                show_mroute_count_per_channel_oil(&sr->c_oil, json, vty);
 
-       if (uj) {
-               vty_out(vty, "%s\n",
-                       json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       }
+       if (uj)
+               vty_json(vty, json);
 }
 
 DEFUN (show_ip_mroute_count,
@@ -6616,12 +6528,8 @@ DEFUN (show_ip_mroute_summary,
 
        show_mroute_summary(vrf->info, vty, json);
 
-       if (uj) {
-               vty_out(vty, "%s\n",
-                       json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       }
+       if (uj)
+               vty_json(vty, json);
        return CMD_SUCCESS;
 }
 
@@ -6655,12 +6563,8 @@ DEFUN (show_ip_mroute_summary_vrf_all,
                        json_object_object_add(json, vrf->name, json_vrf);
        }
 
-       if (uj) {
-               vty_out(vty, "%s\n",
-                       json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       }
+       if (uj)
+               vty_json(vty, json);
 
        return CMD_SUCCESS;
 }
@@ -7588,9 +7492,7 @@ static void ip_pim_ssm_show_group_range(struct pim_instance *pim,
                json_object *json;
                json = json_object_new_object();
                json_object_string_add(json, "ssmGroups", range_str);
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
+               vty_json(vty, json);
        } else
                vty_out(vty, "SSM group range : %s\n", range_str);
 }
@@ -7640,9 +7542,7 @@ static void ip_pim_ssm_show_group_type(struct pim_instance *pim,
                json_object *json;
                json = json_object_new_object();
                json_object_string_add(json, "groupType", type_str);
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
+               vty_json(vty, json);
        } else
                vty_out(vty, "Group type : %s\n", type_str);
 }
@@ -9968,12 +9868,8 @@ DEFUN (show_ip_msdp_mesh_group,
        SLIST_FOREACH (mg, &pim->msdp.mglist, mg_entry)
                ip_msdp_show_mesh_group(vty, mg, json);
 
-       if (uj) {
-               vty_out(vty, "%s\n",
-                       json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       }
+       if (uj)
+               vty_json(vty, json);
 
        return CMD_SUCCESS;
 }
@@ -10009,12 +9905,9 @@ DEFUN (show_ip_msdp_mesh_group_vrf_all,
                        ip_msdp_show_mesh_group(vty, mg, vrf_json);
        }
 
-       if (uj) {
-               vty_out(vty, "%s\n",
-                       json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       }
+       if (uj)
+               vty_json(vty, json);
+
 
        return CMD_SUCCESS;
 }
@@ -10066,11 +9959,8 @@ static void ip_msdp_show_peers(struct pim_instance *pim, struct vty *vty,
                }
        }
 
-       if (uj) {
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       }
+       if (uj)
+               vty_json(vty, json);
 }
 
 static void ip_msdp_show_peers_detail(struct pim_instance *pim, struct vty *vty,
@@ -10174,11 +10064,8 @@ static void ip_msdp_show_peers_detail(struct pim_instance *pim, struct vty *vty,
                }
        }
 
-       if (uj) {
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       }
+       if (uj)
+               vty_json(vty, json);
 }
 
 DEFUN (show_ip_msdp_peer_detail,
@@ -10322,11 +10209,8 @@ static void ip_msdp_show_sa(struct pim_instance *pim, struct vty *vty, bool uj)
                }
        }
 
-       if (uj) {
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       }
+       if (uj)
+               vty_json(vty, json);
 }
 
 static void ip_msdp_show_sa_entry_detail(struct pim_msdp_sa *sa,
@@ -10415,11 +10299,8 @@ static void ip_msdp_show_sa_detail(struct pim_instance *pim, struct vty *vty,
                                             json);
        }
 
-       if (uj) {
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       }
+       if (uj)
+               vty_json(vty, json);
 }
 
 DEFUN (show_ip_msdp_sa_detail,
@@ -10500,11 +10381,8 @@ static void ip_msdp_show_sa_addr(struct pim_instance *pim, struct vty *vty,
                }
        }
 
-       if (uj) {
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       }
+       if (uj)
+               vty_json(vty, json);
 }
 
 static void ip_msdp_show_sa_sg(struct pim_instance *pim, struct vty *vty,
@@ -10529,11 +10407,8 @@ static void ip_msdp_show_sa_sg(struct pim_instance *pim, struct vty *vty,
                }
        }
 
-       if (uj) {
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       }
+       if (uj)
+               vty_json(vty, json);
 }
 
 DEFUN (show_ip_msdp_sa_sg,
@@ -10703,11 +10578,8 @@ static void pim_show_vxlan_sg(struct pim_instance *pim,
        cwd.json = json;
        hash_iterate(pim->vxlan.sg_hash, pim_show_vxlan_sg_hash_entry, &cwd);
 
-       if (uj) {
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       }
+       if (uj)
+               vty_json(vty, json);
 }
 
 static void pim_show_vxlan_sg_match_addr(struct pim_instance *pim,
@@ -10739,11 +10611,8 @@ static void pim_show_vxlan_sg_match_addr(struct pim_instance *pim,
        cwd.addr_match = true;
        hash_iterate(pim->vxlan.sg_hash, pim_show_vxlan_sg_hash_entry, &cwd);
 
-       if (uj) {
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       }
+       if (uj)
+               vty_json(vty, json);
 }
 
 static void pim_show_vxlan_sg_one(struct pim_instance *pim,
@@ -10805,11 +10674,8 @@ static void pim_show_vxlan_sg_one(struct pim_instance *pim,
                }
        }
 
-       if (uj) {
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       }
+       if (uj)
+               vty_json(vty, json);
 }
 
 DEFUN (show_ip_pim_vxlan_sg,
@@ -10870,11 +10736,8 @@ static void pim_show_vxlan_sg_work(struct pim_instance *pim,
        for (ALL_LIST_ELEMENTS_RO(pim_vxlan_p->work_list, node, vxlan_sg))
                pim_show_vxlan_sg_entry(vxlan_sg, &cwd);
 
-       if (uj) {
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       }
+       if (uj)
+               vty_json(vty, json);
 }
 
 DEFUN_HIDDEN (show_ip_pim_vxlan_sg_work,