summaryrefslogtreecommitdiff
path: root/json-glib/json-array.c
diff options
context:
space:
mode:
Diffstat (limited to 'json-glib/json-array.c')
-rw-r--r--json-glib/json-array.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/json-glib/json-array.c b/json-glib/json-array.c
index 4834cdc..ecb9e72 100644
--- a/json-glib/json-array.c
+++ b/json-glib/json-array.c
@@ -85,6 +85,30 @@ json_array_sized_new (guint n_elements)
return array;
}
+JsonArray *
+json_array_copy (JsonArray *array,
+ JsonNode *new_parent)
+{
+ JsonArray *copy;
+ guint i;
+
+ copy = json_array_sized_new (array->elements->len);
+ for (i = 0; i < array->elements->len; i++)
+ {
+ JsonNode *child_copy;
+
+ child_copy = json_node_copy (g_ptr_array_index (array->elements, i));
+ child_copy->parent = new_parent;
+ g_ptr_array_index (copy->elements, i) = child_copy;
+ }
+ copy->elements->len = array->elements->len;
+
+ copy->immutable_hash = array->immutable_hash;
+ copy->immutable = array->immutable;
+
+ return copy;
+}
+
/**
* json_array_ref:
* @array: a #JsonArray