summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/reference/json-glib-sections.txt1
-rw-r--r--json-glib/json-node.c20
-rw-r--r--json-glib/json-types.h1
3 files changed, 22 insertions, 0 deletions
diff --git a/doc/reference/json-glib-sections.txt b/doc/reference/json-glib-sections.txt
index 3818338..2875663 100644
--- a/doc/reference/json-glib-sections.txt
+++ b/doc/reference/json-glib-sections.txt
@@ -71,6 +71,7 @@ json_node_set_int
json_node_get_int
json_node_set_string
json_node_get_string
+json_node_dup_string
<SUBSECTION>
json_node_get_parent
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
diff --git a/json-glib/json-types.h b/json-glib/json-types.h
index 31e3aa7..a95f7fd 100644
--- a/json-glib/json-types.h
+++ b/json-glib/json-types.h
@@ -112,6 +112,7 @@ void json_node_get_value (JsonNode *node,
void json_node_set_string (JsonNode *node,
const gchar *value);
G_CONST_RETURN gchar *json_node_get_string (JsonNode *node);
+gchar * json_node_dup_string (JsonNode *node);
void json_node_set_int (JsonNode *node,
gint value);
gint json_node_get_int (JsonNode *node);