summaryrefslogtreecommitdiffstats
path: root/lib/json.h
diff options
context:
space:
mode:
authorDavid Schweizer <dschweizer@opensourcerouting.org>2022-01-12 12:32:33 +0100
committerDavid Schweizer <dschweizer@opensourcerouting.org>2022-01-12 12:32:33 +0100
commit0b11b56abd258a65786c99d18412149c5963ca19 (patch)
treed5ed00ac5f7500daf4a7e8e7b234cc02677a2617 /lib/json.h
parentospf6d: add LSA statistics to LSA database (diff)
downloadfrr-0b11b56abd258a65786c99d18412149c5963ca19.tar.xz
frr-0b11b56abd258a65786c99d18412149c5963ca19.zip
ospf6d: add LSA stats to show area json output
Signed-off-by: David Schweizer <dschweizer@opensourcerouting.org>
Diffstat (limited to 'lib/json.h')
-rw-r--r--lib/json.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/json.h b/lib/json.h
index 9d33ac7ae..fcaa84c81 100644
--- a/lib/json.h
+++ b/lib/json.h
@@ -42,6 +42,15 @@ extern "C" {
json_object_iter_equal(&(joi), &(join)) == 0; \
json_object_iter_next(&(joi)))
+#define JSON_OBJECT_NEW_ARRAY(json_func, fields, n) \
+ ({ \
+ struct json_object *_json_array = json_object_new_array(); \
+ for (int _i = 0; _i < (n); _i++) \
+ json_object_array_add(_json_array, \
+ (json_func)((fields)[_i])); \
+ (_json_array); \
+ })
+
extern bool use_json(const int argc, struct cmd_token *argv[]);
extern void json_object_string_add(struct json_object *obj, const char *key,
const char *s);