summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/json.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/json.h b/include/json.h
index 9257ff2..5245115 100644
--- a/include/json.h
+++ b/include/json.h
@@ -107,7 +107,7 @@ struct json *json_new_null(void);
char *json_print(struct json *json);
#define json_foreach(e, o) \
- for (e = o->children->items[0]; e; e = e->next)
+ for (e = json_is_object(o) || json_is_array(o) ? o->children->items[0] : NULL; e; e = e->next)
static inline bool json_is_object(struct json *json) {
return json && json->type == JSON_OBJECT;