Skip to content

Commit

Permalink
json_object_merge(): Only recurse if both source and destination are …
Browse files Browse the repository at this point in the history
…objects.

Turns out that we might like to completely overwrite objects with other data types.
  • Loading branch information
nmlgc committed May 18, 2014
1 parent cca89be commit 5f31a8f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion thcrap/src/jansson_ex.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 5f31a8f

Please # to comment.