From 46bc58545b95ee1cba1292dcaeb46c60533e0184 Mon Sep 17 00:00:00 2001 From: "Anna (navi) Figueiredo Gomes" Date: Thu, 7 Mar 2024 21:50:08 +0100 Subject: json.h, object.c, array.c: const correct getters Signed-off-by: Anna (navi) Figueiredo Gomes --- src/array.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/array.c') 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); -- cgit v1.2.3