diff options
Diffstat (limited to 'src/object.c')
-rw-r--r-- | src/object.c | 12 |
1 files changed, 10 insertions, 2 deletions
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); |