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/object.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/object.c') diff --git a/src/object.c b/src/object.c index 7178bdd..fea4787 100644 --- a/src/object.c +++ b/src/object.c @@ -133,7 +133,7 @@ bool json_object_add(struct json *dest, const char *key, struct json *src) { return true; } -struct json *json_object_get(const struct json *obj, const char *key) { +struct json *json_object_get_mut(struct json *obj, const char *key) { if (obj->type != JSON_OBJECT) return NULL; struct json *j = NULL; json_foreach(j, obj) { @@ -143,7 +143,7 @@ struct json *json_object_get(const struct json *obj, const char *key) { return j; } -struct json *json_object_getn(const struct json *obj, const char *key, size_t n) { +struct json *json_object_getn_mut(struct json *obj, const char *key, size_t n) { if (obj->type != JSON_OBJECT) return NULL; struct json *j = NULL; json_foreach(j, obj) { @@ -153,6 +153,14 @@ struct json *json_object_getn(const struct json *obj, const char *key, size_t n) return j; } +const struct json *json_object_get_const(const struct json *obj, const char *key) { + return json_object_get_mut((struct json *) obj, key); +} + +const struct json *json_object_getn_const(const struct json *obj, const char *key, size_t n) { + return json_object_getn_mut((struct json *) obj, key, n); +} + struct json *json_object_add_object(struct json *dest, const char *key) { struct json *obj = json_new_object(); json_object_add(dest, key, obj); -- cgit v1.2.3