summaryrefslogtreecommitdiff
path: root/lib/json.h
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2022-02-06 21:46:13 +0300
committerGitHub <noreply@github.com>2022-02-06 21:46:13 +0300
commit88386db620e1e31d99a158ea75ad460fe78e61e0 (patch)
treebfe59f47978d64bcf35262730d9e794ee1a78cc8 /lib/json.h
parentc1b7277445196f434f7e4d8f9da8f2acf54f6b7e (diff)
parent0b11b56abd258a65786c99d18412149c5963ca19 (diff)
Merge pull request #10323 from opensourcerouting/ospf6-lsa-stats
ospf6d: LSA statistics
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 9d33ac7ae3..fcaa84c816 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);