diff --git a/tests/main.c b/tests/main.c index 8ad20ef..021b593 100644 --- a/tests/main.c +++ b/tests/main.c @@ -6,6 +6,7 @@ */ #include +#include #include "clar_test.h" diff --git a/tests/searpc.c b/tests/searpc.c index a1610d4..e10a619 100644 --- a/tests/searpc.c +++ b/tests/searpc.c @@ -336,22 +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) { int count = 0; - const char *key; - const json_t *value; - json_object_foreach(((json_t*)obj), key, value) { + + json_t *member; + member = json_object_iter ((json_t*)obj); + while (member != NULL) { + member = json_object_iter_next ((json_t*)obj, member); count++; }