diff options
author | Emmanuele Bassi <ebassi@openedhand.com> | 2007-10-08 18:29:44 +0100 |
---|---|---|
committer | Emmanuele Bassi <ebassi@openedhand.com> | 2007-10-08 18:29:44 +0100 |
commit | daeef3345c3a7f3325cea8c945f0e1d814defcc1 (patch) | |
tree | 28498a405ba66d0d24de6d3fd94560f1eb83eabe /json-glib/json-node.c | |
parent | b12efcec57fff6e7637fc924fc50333b97eb2594 (diff) | |
download | json-glib-daeef3345c3a7f3325cea8c945f0e1d814defcc1.tar.gz |
Add json_node_dup_string()
The newly added json_node_dup_string() is a convenience function for
getting a copy of the string contained inside a JsonNode.
Diffstat (limited to 'json-glib/json-node.c')
-rw-r--r-- | json-glib/json-node.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/json-glib/json-node.c b/json-glib/json-node.c index 8e7d5ad..7f1e9a7 100644 --- a/json-glib/json-node.c +++ b/json-glib/json-node.c @@ -448,6 +448,26 @@ json_node_get_string (JsonNode *node) } /** + * json_node_dup_string: + * @node: a #JsonNode of type %JSON_NODE_VALUE + * + * Gets a copy of the string value stored inside a #JsonNode + * + * Return value: a newly allocated string containing a copy of + * the #JsonNode contents + */ +gchar * +json_node_dup_string (JsonNode *node) +{ + g_return_val_if_fail (JSON_NODE_TYPE (node) == JSON_NODE_VALUE, NULL); + + if (G_VALUE_TYPE (&(node->data.value)) == G_TYPE_STRING) + return g_value_dup_string (&(node->data.value)); + + return NULL; +} + +/** * json_node_set_int: * @node: a #JsonNode of type %JSON_NODE_VALUE * @value: an integer value |