diff options
author | Emmanuele Bassi <ebassi@openedhand.com> | 2007-11-21 20:41:42 +0000 |
---|---|---|
committer | Emmanuele Bassi <ebassi@openedhand.com> | 2007-11-21 20:41:42 +0000 |
commit | cf2eceeb69ccbda4f2ff583ee7869c7fd3cda603 (patch) | |
tree | cb53f0d635d9556b35f2fc66fd43020110baeaa8 /json-glib/json-object.c | |
parent | 5a4a8761af0562fbee8e1a56ce1771a20c1ad8e3 (diff) | |
download | json-glib-cf2eceeb69ccbda4f2ff583ee7869c7fd3cda603.tar.gz |
Add API to retrieve copies of the nodes inside objects and arrays
Getting copies of the nodes might work better for high level languages
binding the JSON-GLib API, because they can manage the lifetime of the
returned values using their own rules.
Diffstat (limited to 'json-glib/json-object.c')
-rw-r--r-- | json-glib/json-object.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/json-glib/json-object.c b/json-glib/json-object.c index c6eeff1..e0b4181 100644 --- a/json-glib/json-object.c +++ b/json-glib/json-object.c @@ -254,6 +254,35 @@ json_object_get_values (JsonObject *object) } /** + * json_object_dup_member: + * @object: a #JsonObject + * @member_name: the name of the JSON object member to access + * + * Retrieves a copy of the #JsonNode containing the value of @member_name + * inside a #JsonObject + * + * Return value: a copy of the node for the requested object member + * or %NULL. Use json_node_free() when done. + * + * Since: 0.6 + */ +JsonNode * +json_object_dup_member (JsonObject *object, + const gchar *member_name) +{ + JsonNode *retval; + + g_return_val_if_fail (object != NULL, NULL); + g_return_val_if_fail (member_name != NULL, NULL); + + retval = json_object_get_member (object, member_name); + if (!retval) + return NULL; + + return json_node_copy (retval); +} + +/** * json_object_get_member: * @object: a #JsonObject * @member_name: the name of the JSON object member to access |