diff --git a/lib/searpc-utils.h b/lib/searpc-utils.h index 141aa68..467e69b 100644 --- a/lib/searpc-utils.h +++ b/lib/searpc-utils.h @@ -66,7 +66,7 @@ inline static const json_t *json_array_get_json_or_null_element (json_t *array, inline static void json_array_add_json_or_null_element (json_t *array, const json_t *value) { if (value) { - json_t *obj = json_deep_copy(value); + json_t *obj = json_deep_copy((json_t*)value); json_array_append_new (array, obj); } else { json_array_append_new (array, json_null ()); diff --git a/tests/searpc.c b/tests/searpc.c index a293f15..a1610d4 100644 --- a/tests/searpc.c +++ b/tests/searpc.c @@ -336,6 +336,15 @@ test_searpc__json_return_type (void) json_decref(result); } +// The macro `json_object_foreach` is not defined in older versions of +// libjansson. +#ifndef json_object_foreach +#define json_object_foreach(object, key, value) \ + for(key = json_object_iter_key(json_object_iter(object)); \ + key && (value = json_object_iter_value(json_object_key_to_iter(key))); \ + key = json_object_iter_key(json_object_iter_next(object, json_object_key_to_iter(key)))) +#endif + json_t * count_json_kvs (const json_t *obj, GError **error) {