diff options
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 8e6b293..4335256 100644 --- a/json-glib/json-object.c +++ b/json-glib/json-object.c @@ -72,6 +72,35 @@ json_object_new (void) return object; } +JsonObject * +json_object_copy (JsonObject *object, + JsonNode *new_parent) +{ + JsonObject *copy; + GList *cur; + + copy = json_object_new (); + + for (cur = object->members_ordered.head; cur != NULL; cur = cur->next) + { + gchar *name; + JsonNode *child_copy; + + name = g_strdup (cur->data); + + child_copy = json_node_copy (g_hash_table_lookup (object->members, name)); + child_copy->parent = new_parent; + + g_hash_table_insert (copy->members, name, child_copy); + g_queue_push_tail (©->members_ordered, name); + } + + copy->immutable_hash = object->immutable_hash; + copy->immutable = object->immutable; + + return copy; +} + /** * json_object_ref: * @object: a #JsonObject |