From 5f31a8f026308bebc80484943913b43b779315de Mon Sep 17 00:00:00 2001 From: nmlgc Date: Sun, 18 May 2014 20:43:00 +0200 Subject: [PATCH] json_object_merge(): Only recurse if both source and destination are objects. Turns out that we might like to completely overwrite objects with other data types. --- thcrap/src/jansson_ex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/thcrap/src/jansson_ex.c b/thcrap/src/jansson_ex.c index 7f9fe78c..e85cd023 100644 --- a/thcrap/src/jansson_ex.c +++ b/thcrap/src/jansson_ex.c @@ -195,7 +195,7 @@ json_t* json_object_merge(json_t *old_obj, const json_t *new_obj) } json_object_foreach((json_t*)new_obj, key, new_val) { json_t *old_val = json_object_get(old_obj, key); - if(json_is_object(old_val)) { + if(json_is_object(old_val) && json_is_object(new_val)) { // Recursion! json_object_merge(old_val, new_val); } else {