diff options
| author | Eric Kinzie <ekinzie@labn.net> | 2022-09-02 16:33:21 +0200 |
|---|---|---|
| committer | Louis Scalbert <louis.scalbert@6wind.com> | 2023-04-18 11:33:15 +0200 |
| commit | 42bf1afa5a06926839fb4ccf0bab27aa1a956bae (patch) | |
| tree | fae281539da09ca1ce0f1fba76e2796f59d2a470 /lib/termtable.h | |
| parent | 06ddebc822aea825b26eece86e440106e13f6b6d (diff) | |
lib: convert termtable to json
Add a function that returns a JSON-C structure containing a representation
of a termtable. This is intended to be a quick way to implement JSON
output to CLI commands.
Signed-off-by: Eric Kinzie <ekinzie@labn.net>
Diffstat (limited to 'lib/termtable.h')
| -rw-r--r-- | lib/termtable.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/termtable.h b/lib/termtable.h index 3aa8caee89..7258682bd8 100644 --- a/lib/termtable.h +++ b/lib/termtable.h @@ -8,6 +8,7 @@ #define _TERMTABLE_H_ #include <zebra.h> +#include "lib/json.h" #ifdef __cplusplus extern "C" { @@ -277,6 +278,17 @@ void ttable_rowseps(struct ttable *tt, unsigned int row, */ char *ttable_dump(struct ttable *tt, const char *newline); +/** + * Convert a table to a JSON array of objects. + * + * Caller must free the returned json_object structure. + * + * @param tt the table to convert + * @param formats an array of characters indicating what JSON type should be + * used. + */ +json_object *ttable_json(struct ttable *tt, const char *const formats); + #ifdef __cplusplus } #endif |
