From 28928a2f1cbe83a2f1bf699c915daa6eca80f587 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 15 Oct 2007 10:25:09 +0100 Subject: Add API for removing nodes from arrays and objects Write and document json_object_remove_member() and json_array_remove_element() which can be used to remove a JsonNode from a JsonObject or a JsonArray respectively. This way, the JsonObject and JsonArray are API-complete and the object model can be manipulated in code. --- json-glib/json-array.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'json-glib/json-array.c') diff --git a/json-glib/json-array.c b/json-glib/json-array.c index 70b82dd..7e23621 100644 --- a/json-glib/json-array.c +++ b/json-glib/json-array.c @@ -232,3 +232,21 @@ json_array_add_element (JsonArray *array, g_ptr_array_add (array->elements, node); } + +/** + * json_array_remove_element: + * @array: a #JsonArray + * @index_: the position of the element to be removed + * + * Removes the #JsonNode inside @array at @index_ freeing its allocated + * resources. + */ +void +json_array_remove_element (JsonArray *array, + guint index_) +{ + g_return_if_fail (array != NULL); + g_return_if_fail (index_ < array->elements->len); + + json_node_free (g_ptr_array_remove_index (array->elements, index_)); +} -- cgit v1.2.1