diff options
Diffstat (limited to 'src/array.c')
-rw-r--r-- | src/array.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/array.c b/src/array.c index edf7ed9..c34a8e5 100644 --- a/src/array.c +++ b/src/array.c @@ -66,13 +66,17 @@ bool json_array_append(struct json *dest, struct json *src) { return true; } -struct json *json_array_get(const struct json *json, size_t index) { - if (index > json->children->nitems) +struct json *json_array_get_mut(struct json *json, size_t index) { + if (json->type != JSON_ARRAY || index > json->children->nitems) return NULL; return json->children->items[index]; } +const struct json *json_array_get_const(const struct json *array, size_t index) { + return json_array_get_mut((struct json *) array, index); +} + struct json *json_array_add_object(struct json *dest) { struct json *obj = json_new_object(); json_array_append(dest, obj); |