2 ms·
From a computer science point of view, what kind of transformations are impossible to express in jmespath but are possible in jq?
by remram 5y ago
From a computer science point of view, what kind of transformations are impossible to express in jmespath but are possible in jq?
- mdaniel 5y agoI dunno how to speak to your "computer science" part, but pragmatically anything that requires a "backreference", because unlike with JSONPath (and, of course, jq) there are no "root object" references $ printf '{"a": {"b":"c", "d":["d0","d1"]}}' | jq -r '[ .a as $a | $a.d[] | {x: ., y: $a.b}]' [ { "x": "d0", "y": "c" }, { "x": "d1", "y": "c" } ] and I realize this isn't as pure CS-y as you were asking, but this syntax is hell on quoting $ printf '["a","b"]' | jp -u 'join(`"\n"`, @)' # vs $ printf '["a","b"]' | jq -r 'join("\n")'
- remram 5y agoI see. The need to quote JSON values and the need for @ seem like a high price to pay for removing the . in field accesses. I also find jq more intuitive but I really dislike that we have three standards each used by a number of tools, e.g. jsonpath, jmespath, and jq.