]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: Allow json to work across different versions.
authorDonald Sharp <sharpd@cumulusnetworks.com>
Sat, 3 Dec 2016 01:39:24 +0000 (20:39 -0500)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Tue, 17 Jan 2017 23:46:24 +0000 (18:46 -0500)
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>
lib/json.c
lib/json.h

index 3edd146a8f4a2dacc8e085c06139a91fdf1edac8..ccbecb726ad420d31923f29dd2813bd7c193cf63 100644 (file)
@@ -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
index bacc799519a902fa834eb313f6f702c2e6c691a5..7e98614280eefde01ccbe35352088775377a8523 100644 (file)
  * so let's just turn it back to the original usage.
  */
 #define json_object_to_json_string_ext(A, B) json_object_to_json_string (A)
+
+extern int json_object_object_get_ex(struct json_object *obj,
+                                          const char *key,
+                                          struct json_object **value);
 #endif
 
 #include "command.h"