From 4c66331cf9243e0e1c8ef7048066762b381f6d74 Mon Sep 17 00:00:00 2001 From: William Brawner Date: Sat, 21 Mar 2020 09:35:02 -0600 Subject: [PATCH] Update JSON parsing for backwards compatibility The latest stable release for debian ships with libjson-c 0.12, which doesn't contain the json_pointer.h file. This change should hopefully work for version 0.13.x as well. --- src/network.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/network.c b/src/network.c index 3713e83..41128a9 100644 --- a/src/network.c +++ b/src/network.c @@ -21,7 +21,6 @@ #include #include #include -#include #include "config.h" #include "log.h" #include "network.h" @@ -155,7 +154,7 @@ static int parse_status(char * raw_json) { write_log(PIHELPER_LOG_DEBUG, "%s", json_object_to_json_string_ext(jobj, JSON_C_TO_STRING_PRETTY)); json_object *status; const char * status_string; - if (json_pointer_get(jobj, "/status", &status) == 0 + if (json_object_object_get_ex(jobj, "/status", &status) == 0 && (status_string = json_object_get_string(status)) != NULL) { if (strstr(status_string, "enabled") == status_string) { retval = PIHELPER_ENABLED;