5 ms·
I'd long for such a tool with a better comprehensible query language.
by mkesper 6y ago
I'd long for such a tool with a better comprehensible query language.
- rbrtdrmpc- 6y agothis
- cube2222 6y agoIf so, and for anybody else having this wish, check out jql[0], I've created it exactly for this reason, to have the most common jq operations available in a more uniform and easier to use interface. [0]: https://github.com/cube2222/jql https://github.com/cube2222/jql
- davesnx 6y agoNice! I will try to bring it to the brenchmark, thanks for sharing
- peterohler 6y agoThe oj command in https://github.com/ohler55/ojg https://github.com/ohler55/ojg uses JSONPath as the query and filter language. Maybe it is more in line with what you are looking for.
- diggan 6y agoGive jet a try! Uses a lightweight query language over EDN. If you're familiar with Clojure, it'll be very natural to use and if you're not familiar with Clojure, the query language used is very easy to pickup :) https://github.com/borkdude/jet/blob/master/doc/query.md https://github.com/borkdude/jet/blob/master/doc/query.md
- JamesSwift 6y agoFor anything moderately complex I iterate using https://jqplay.org/ https://jqplay.org/. Life is much better since I started doing that.
- cube2222 6y agoHint: you can do live jq query preview for any jq-like command using fzf. It looks like this for jql, an alternative I've created (you can find it in a neighboring comment): echo '' | fzf --print-query --preview-window wrap --preview 'cat test.json | jql {q}'
- benibela 6y agoThere is XPath 3.1: https://www.w3.org/TR/xpath-31/#id-lookup https://www.w3.org/TR/xpath-31/#id-lookup It is more verbose, like you get the size of something with array:size or map:size functions, so it is more readable I am implementing it in Xidel 0.9.9+: http://www.videlibri.de/xidel.html http://www.videlibri.de/xidel.html
- jeffbee 6y agoXPath is really useful and `xmlstarlet` is/was jq before jq existed. These days it's relatively rare to get data in XML instead of JSON, though.
- benibela 6y agoThis is about JSON xmlstarlet supports XPath 1, but the W3C did not stop there. They made XPath 2 featuring variables, lists and regular expressions, XPath 3 featuring higher order function, and finally XPath 3.1 featuring JSON support. For example, echo '[{"a": 1}, {"a": 2, "b": 3}, {"c": 4}]' | xidel - -e '?*?a!(. * 100)' will print 100 and 200. Or the same with a verbose syntax: echo '[{"a": 1}, {"a": 2, "b": 3}, {"c": 4}]' | xidel - -e 'for $obj in array:flatten(.) return map:get($obj, "a") * 100'
- jeffbee 6y agoThat's news to me. Very cool actually. It's not far from jq on speed, either. Looks like you are the maintainer of this tool, so thanks! ~/xidel % time ./xidel - -e '?SitusAddress!(.)' < ~/parcels | wc **** Processing: stdin:/// **** 29066 149317 903704 ./xidel - -e '?SitusAddress!(.)' < ~/parcels 2.55s user 0.18s system 99% cpu 2.733 total wc 0.01s user 0.00s system 0% cpu 2.733 total ~/xidel % time jq -r '.SitusAddress' < ~/parcels | wc 29066 149317 903704 jq -r '.SitusAddress' < ~/parcels 0.95s user 0.00s system 99% cpu 0.958 total wc 0.00s user 0.01s system 1% cpu 0.957 total
- aasasd 6y agoI've collected a bunch of alternatives to look at, see here: https://news.ycombinator.com/item?id=24470715 https://news.ycombinator.com/item?id=24470715