From 6950cd203b99662e4240266d0b40a8b8ba99528a Mon Sep 17 00:00:00 2001 From: Daniel Griscom Date: Sun, 12 May 2013 15:03:26 -0400 Subject: [PATCH] Add json_array_foreach() #define, parallelling json_object_foreach() --- src/jansson.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/jansson.h b/src/jansson.h index e53a301..6bbc0cb 100644 --- a/src/jansson.h +++ b/src/jansson.h @@ -148,6 +148,11 @@ int json_object_iter_set_new(json_t *object, void *iter, json_t *value); 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)))) +#define json_array_foreach(array, index, value) \ + for(index = 0; \ + index < json_array_size(array) && (value = json_array_get(array, index)); \ + index++) + static JSON_INLINE int json_object_set(json_t *object, const char *key, json_t *value) {