5 ms·
For a tool I only use very occasionally I find jq's syntax to be too unique with too steep of a learning curve. Every time I reach for it I have to spend a bunc
by guelo 4y ago
For a tool I only use very occasionally I find jq's syntax to be too unique with too steep of a learning curve. Every time I reach for it I have to spend a bunch of time reading the manual trying to think like it does.
I wish there was something for querying json that had more of a xpath or even a sql-like syntax, or GraphQL with the addition of wildcards.
- bachmeier 4y agodsq works for me: https://github.com/multiprocessio/dsq https://github.com/multiprocessio/dsq
- mdaniel 4y ago> dsq registers go-sqlite3-stdlib so you get access to numerous statistics, url, math, string, and regexp functions that aren't part of the SQLite base. (https://github.com/multiprocessio/dsq#standard-library https://github.com/multiprocessio/dsq#standard-library) Ah, I wondered if they rolled their own SQL parser, but no, I now see the sqlite.go in the repo and all is made clear
- youngtaff 4y agoThere’s some limitations in dsq which means it doesn’t query sub objects that have varying fields - they just remain as JSON strings
- pcthrowaway 4y agoThe trick is to use it daily. The learning curve isn't worse than vim
- tux2bsd 4y agoTo use it daily you need a reason, or have the time & will to practice it.
- pcthrowaway 4y agoFair. I guess I think anyone using jq occasionally could probably be using it daily as well. Dealing with JSON data is pretty much standard for anyone developing or consuming a rest API
- tux2bsd 4y ago> I guess I think anyone using jq occasionally could probably be using it daily as well. No. Occasionally: "at infrequent or irregular intervals; now and then."
- mdaniel 4y agoI have a hard time suggesting such a thing, because I find JMESPath incredibly inferior to jq's expressiveness, but if you're in the AWS ecosystem much, you may enjoy https://github.com/jmespath/jp#readme https://github.com/jmespath/jp#readme which uses the same query language as does awscli (https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-filter.html#cli-usage-filter-client-side https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-f...). That may at least pay more dividends than keeping jq's language in your head where it will only ever be used by jq
- defrost 4y agojqp the Text User Interface for playing about with jq might help a bit. You can have your input JSON terminal left, the output post jq terminal right and interactively edit your jq script elements above. ( based upon the Go implementation of jq ) See: https://github.com/noahgorstein/jqp https://github.com/noahgorstein/jqp
- capableweb 4y agoIf you're used to S-expressions/know a bit of Clojure, `jet` is a similar tool that not only allows you to convert between JSON <> EDN, but also has a tiny query language built-in, that is just normal Clojure functions. Clojure really excels at data querying/manipulation, so `jet` is very ergonomic to use. One example: $ echo '{"anApple": 1}' | jet -i json -k '#(-> % csk/->kebab-case keyword)' -o edn {:an-apple 1} Since starting to use jet, I haven't found anything jq could do that jet couldn't also do but with the additional feature of actually being able to read what I've done with it days later. https://github.com/borkdude/jet https://github.com/borkdude/jet
- adammarples 4y agoColumnq is pretty amazing, fully SQL, you can even join them to CSV etc