]> git.proxmox.com Git - mirror_frr.git/commitdiff
lib: Helper function to print empty JSON
authorPooja Jagadeesh Doijode <pdoijode@nvidia.com>
Tue, 7 Feb 2023 22:29:54 +0000 (14:29 -0800)
committerPooja Jagadeesh Doijode <pdoijode@nvidia.com>
Tue, 7 Feb 2023 22:29:54 +0000 (14:29 -0800)
Introduced a helper function to print empty JSON object.

Signed-off-by: Pooja Jagadeesh Doijode <pdoijode@nvidia.com>
lib/vty.c
lib/vty.h

index 2a0bb9446ad521c8023677fe9ca8559fc550a927..8393f67b6d6e8a84385da628d5a8543b7ecb8d16 100644 (file)
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -312,6 +312,13 @@ int vty_json_no_pretty(struct vty *vty, struct json_object *json)
        return vty_json_helper(vty, json, JSON_C_TO_STRING_NOSLASHESCAPE);
 }
 
+void vty_json_empty(struct vty *vty)
+{
+       json_object *json = json_object_new_object();
+
+       vty_json(vty, json);
+}
+
 /* Output current time to the vty. */
 void vty_time_print(struct vty *vty, int cr)
 {
index 45349d91af3741513cbc8faa6556191bcc7e5f57..70c78f5ae8f526b55abcb8b3258bb94420f76561 100644 (file)
--- a/lib/vty.h
+++ b/lib/vty.h
@@ -359,7 +359,7 @@ extern bool vty_set_include(struct vty *vty, const char *regexp);
  */
 extern int vty_json(struct vty *vty, struct json_object *json);
 extern int vty_json_no_pretty(struct vty *vty, struct json_object *json);
-
+extern void vty_json_empty(struct vty *vty);
 /* post fd to be passed to the vtysh client
  * fd is owned by the VTY code after this and will be closed when done
  */