diff options
author | Stephen Dolan <mu@netsoc.tcd.ie> | 2013-05-13 16:15:49 +0100 |
---|---|---|
committer | Stephen Dolan <mu@netsoc.tcd.ie> | 2013-05-13 16:15:49 +0100 |
commit | a625d2821ecb27b87266762545f88d7d4aa59d31 (patch) | |
tree | 82fb4a6e7920673fa7a2570178f22cc47dc07d37 /builtin.c | |
parent | d8706fd4607ee1b5b56debd4da39e3314739f126 (diff) |
Add to_entries, from_entries and with_entries functions.
Closes #97.
Diffstat (limited to 'builtin.c')
-rw-r--r-- | builtin.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -547,6 +547,9 @@ static const char* const jq_builtins[] = { "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));", "def recurse(f): ., (f | select(. != null) | recurse(f));", + "def to_entries: [keys[] as $k | {key: $k, value: .[$k]}];", + "def from_entries: map({(.key): .value}) | add;", + "def with_entries(f): to_entries | map(f) | from_entries;", }; |