Refactor assignment.
New version is much more elegant and probably slower. Uses library functions implemented in jq rather than dedicated opcodes.
This commit is contained in:
1 parent
465a4ec565
commit
d5fdf70434
7 files changed
+19
-53
No files matched your search
@@ -552,6 +552,9 @@ static const char* jq_builtins[] = {
|
||||
"def max_by(f): _max_by_impl(map([f]));",
|
||||
"def min_by(f): _min_by_impl(map([f]));",
|
||||
"def del(f): delpaths([path(f)]);",
|
||||
"def _assign(paths; value): value as $v | fold . as $obj (path(paths) as $p | $obj | setpath($p; $v));",
|
||||
"def _modify(paths; update): fold . as $obj (path(paths) as $p | $obj | setpath($p; getpath($p) | update));",
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user