summaryrefslogtreecommitdiffstats
path: root/lib/json.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2016-12-03 02:39:24 +0100
committerDonald Sharp <sharpd@cumulusnetworks.com>2017-01-18 00:46:24 +0100
commit2047fdb5e741c5e645c0bad2ec43c5eafa8b947f (patch)
treef5a94674321641b7ef36a9e1618be4fffda0319b /lib/json.c
parentlib: Fix clang SA warnings. (diff)
downloadfrr-2047fdb5e741c5e645c0bad2ec43c5eafa8b947f.tar.xz
frr-2047fdb5e741c5e645c0bad2ec43c5eafa8b947f.zip
lib: Allow json to work across different versions.
The json_object_object_get_ex function is not fully available across all versions of json. Write a wrapper to allow it to work. Ticket: CM-13872 Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'lib/json.c')
-rw-r--r--lib/json.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/json.c b/lib/json.c
index 3edd146a8..ccbecb726 100644
--- a/lib/json.c
+++ b/lib/json.c
@@ -87,3 +87,18 @@ json_object_free(struct json_object *obj)
{
json_object_put(obj);
}
+
+#if !defined(HAVE_JSON_C_JSON_H)
+int
+json_object_object_get_ex(struct json_object *obj,
+ const char *key,
+ struct json_object **value)
+{
+ *value = json_object_object_get(obj, key);
+
+ if (*value)
+ return 1;
+
+ return 0;
+}
+#endif