diff options
author | Emmanuele Bassi <ebassi@openedhand.com> | 2007-10-15 10:25:09 +0100 |
---|---|---|
committer | Emmanuele Bassi <ebassi@openedhand.com> | 2007-10-15 10:25:09 +0100 |
commit | 28928a2f1cbe83a2f1bf699c915daa6eca80f587 (patch) | |
tree | 5efa69ef1d28e897623c47bd9ea96a7881bc4958 /json-glib/json-array.c | |
parent | b3ecd6e2fbdd58250427f406c43d60b8cb8d2644 (diff) | |
download | json-glib-28928a2f1cbe83a2f1bf699c915daa6eca80f587.tar.gz |
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.
Diffstat (limited to 'json-glib/json-array.c')
-rw-r--r-- | json-glib/json-array.c | 18 |
1 files changed, 18 insertions, 0 deletions
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_)); +} |