diff options
author | Stephen Dolan <mu@netsoc.tcd.ie> | 2012-12-29 16:43:36 +0000 |
---|---|---|
committer | Stephen Dolan <mu@netsoc.tcd.ie> | 2012-12-29 16:43:36 +0000 |
commit | d5fdf70434a243e6f3bd6967dbc2d28c9144cb29 (patch) | |
tree | 17901a90c2a2ff0a2219fa9bab9a340af95e36c7 /builtin.c | |
parent | 465a4ec565a106e0e4cc1d64214fb2d6d791c8dc (diff) |
Refactor assignment.
New version is much more elegant and probably slower. Uses
library functions implemented in jq rather than dedicated opcodes.
Diffstat (limited to 'builtin.c')
-rw-r--r-- | builtin.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -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));", + }; |