1
0
mirror of https://github.com/stedolan/jq.git synced 2024-05-11 05:55:39 +00:00

Add a recursive object merge strategy and bind it to *

This commit adds a jv_object_merge_recursive function, that performs
recursive object merging, and binds it to multiply when applied to
two objects.

Added docs and tests.

Closes #320
This commit is contained in:
Filippo Valsorda
2014-03-08 03:56:05 +01:00
parent 219bb9ecb7
commit 2aa8a43c5b
5 changed files with 44 additions and 1 deletions

View File

@@ -172,6 +172,8 @@ static jv f_multiply(jv input, jv a, jv b) {
return jv_null();
}
return res;
} else if (jv_get_kind(a) == JV_KIND_OBJECT && jv_get_kind(b) == JV_KIND_OBJECT) {
return jv_object_merge_recursive(a, b);
} else {
return type_error2(a, b, "cannot be multiplied");
}