isisd: fix display of router in show isis database <rtr> json

Display information about a particular router in show isis database in
an single value array for compatibility with the display of all routers.

Fixes: a2cac12a63 ("isisd: Add json to show isis database command.")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
This commit is contained in:
Louis Scalbert 2022-09-05 10:22:52 +02:00
parent 2bd3c6b4ff
commit 980d76c403

View File

@ -2649,6 +2649,7 @@ void show_isis_database_lspdb_json(struct json_object *json,
struct lspdb_head *lspdb,
const char *sysid_str, int ui_level)
{
struct json_object *array_json, *lsp_json;
struct isis_lsp *lsp;
int lsp_count;
struct json_object *lsp_arr_json;
@ -2661,11 +2662,19 @@ void show_isis_database_lspdb_json(struct json_object *json,
}
if (lsp) {
json_object_object_get_ex(json, "lsps", &array_json);
if (!array_json) {
array_json = json_object_new_array();
json_object_object_add(json, "lsps", array_json);
}
lsp_json = json_object_new_object();
json_object_array_add(array_json, lsp_json);
if (ui_level == ISIS_UI_LEVEL_DETAIL)
lsp_print_detail(lsp, NULL, json,
lsp_print_detail(lsp, NULL, lsp_json,
area->dynhostname, area->isis);
else
lsp_print_json(lsp, json, area->dynhostname,
lsp_print_json(lsp, lsp_json, area->dynhostname,
area->isis);
} else if (sysid_str == NULL) {
lsp_arr_json = json_object_new_array();