mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-05-01 05:14:54 +00:00
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>
This commit is contained in:
parent
dd3415b74b
commit
2047fdb5e7
15
lib/json.c
15
lib/json.c
@ -87,3 +87,18 @@ json_object_free(struct json_object *obj)
|
|||||||
{
|
{
|
||||||
json_object_put(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
|
||||||
|
@ -32,6 +32,10 @@
|
|||||||
* so let's just turn it back to the original usage.
|
* 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)
|
#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
|
#endif
|
||||||
|
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user