From 980d76c403de248139339bfea68946b50f0bb338 Mon Sep 17 00:00:00 2001 From: Louis Scalbert Date: Mon, 5 Sep 2022 10:22:52 +0200 Subject: [PATCH] isisd: fix display of router in show isis database 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 --- isisd/isisd.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/isisd/isisd.c b/isisd/isisd.c index 382a6aa3be..2c4cee0607 100644 --- a/isisd/isisd.c +++ b/isisd/isisd.c @@ -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();