mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-08 05:27:47 +00:00
lib: add helpers to print json keys
Add helpers to print json keys in order to prepare the next commits. Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
This commit is contained in:
parent
0c6f14ec14
commit
03b1ee7a39
15
lib/vty.c
15
lib/vty.c
@ -390,6 +390,21 @@ int vty_json_no_pretty(struct vty *vty, struct json_object *json)
|
|||||||
return vty_json_helper(vty, json, JSON_C_TO_STRING_NOSLASHESCAPE);
|
return vty_json_helper(vty, json, JSON_C_TO_STRING_NOSLASHESCAPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void vty_json_key(struct vty *vty, const char *key, bool *first_key)
|
||||||
|
{
|
||||||
|
vty_out(vty, "%s\"%s\":", *first_key ? "{" : ",", key);
|
||||||
|
*first_key = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void vty_json_close(struct vty *vty, bool first_key)
|
||||||
|
{
|
||||||
|
if (first_key)
|
||||||
|
/* JSON was not opened */
|
||||||
|
vty_out(vty, "{");
|
||||||
|
vty_out(vty, "}\n");
|
||||||
|
}
|
||||||
|
|
||||||
void vty_json_empty(struct vty *vty, struct json_object *json)
|
void vty_json_empty(struct vty *vty, struct json_object *json)
|
||||||
{
|
{
|
||||||
json_object *jsonobj = json;
|
json_object *jsonobj = json;
|
||||||
|
@ -378,6 +378,8 @@ 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(struct vty *vty, struct json_object *json);
|
||||||
extern int vty_json_no_pretty(struct vty *vty, struct json_object *json);
|
extern int vty_json_no_pretty(struct vty *vty, struct json_object *json);
|
||||||
|
void vty_json_key(struct vty *vty, const char *key, bool *first_key);
|
||||||
|
void vty_json_close(struct vty *vty, bool first_key);
|
||||||
extern void vty_json_empty(struct vty *vty, struct json_object *json);
|
extern void vty_json_empty(struct vty *vty, struct json_object *json);
|
||||||
/* post fd to be passed to the vtysh client
|
/* post fd to be passed to the vtysh client
|
||||||
* fd is owned by the VTY code after this and will be closed when done
|
* fd is owned by the VTY code after this and will be closed when done
|
||||||
|
Loading…
Reference in New Issue
Block a user