itchyny
itchyny
Fixing the precedence to what you expected will break existing scripts so I'm afraid it is unlikely to be fixed.
I remember that this not precedence problem, the parser only accepts `Term` for binding expression. https://github.com/stedolan/jq/blob/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8/src/parser.y#L348
Interesting issue. Firstly I wrote a simple implementation using reduce. ```jq def pick($paths): . as $root | reduce $paths[] as $path ({}; . + { ($path): $root[$path] }); ``` ```sh...
Considering picking a few paths from a large JSON (e.x. pick only id and name from GitHub API v3 object), I think it's better not to iterate though all the...
> If your comment is about def projection, it is misdirected, as allpaths is applied only to the template. Ooops, sorry about that.
Maybe we can implement `haspath` builtin as well?
@pkoppstein Maybe `haspath($p)` does not need to list all the paths. ```jq seq 10000 | jq --slurp ' def allpaths: # include paths to null def conditional_recurse(f): def r: .,...
I suggest following implementation. ```jq def haspath($path): ($path|length) == 0 or (type | . == "object" or . == "array") and has($path[0]) and (.[$path[0]]|haspath($path[1:])); def pick($paths): . as $root |...
> Please read up on TCO on the jq wiki. You could start at https://github.com/stedolan/jq/wiki/Advanced-Topics#tail-call-optimization Thanks, mate.
This is duplicate of #2051.