News for hackers. Stuff that matters.
Re:Jq Internals: Backtracking (2017) by guelo on Wednesday October 05, 2022 @07:28PM (#33102517)
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.

Re:Jq Internals: Backtracking (2017) by capableweb on Thursday October 06, 2022 @05:25AM (#33106255)
If 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

Re:Jq Internals: Backtracking (2017) by mdaniel on Wednesday October 05, 2022 @11:43PM (#33104130)
I 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 which uses the same query language as does awscli (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
Re:Jq Internals: Backtracking (2017) by defrost on Thursday October 06, 2022 @02:52AM (#33105235)
jqp 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

Re:Jq Internals: Backtracking (2017) by bachmeier on Wednesday October 05, 2022 @09:29PM (#33103275)
Re:Jq Internals: Backtracking (2017) by mdaniel on Wednesday October 05, 2022 @11:38PM (#33104103)
> 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)

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

Re:Jq Internals: Backtracking (2017) by youngtaff on Thursday October 06, 2022 @03:33AM (#33105517)
There’s some limitations in dsq which means it doesn’t query sub objects that have varying fields - they just remain as JSON strings
Re:Jq Internals: Backtracking (2017) by pcthrowaway on Wednesday October 05, 2022 @11:16PM (#33103958)
The trick is to use it daily. The learning curve isn't worse than vim
Re:Jq Internals: Backtracking (2017) by tux2bsd on Thursday October 06, 2022 @03:10AM (#33105360)
To use it daily you need a reason, or have the time & will to practice it.
Re:Jq Internals: Backtracking (2017) by pcthrowaway on Thursday October 06, 2022 @03:56AM (#33105672)
Fair. 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
Re:Jq Internals: Backtracking (2017) by tux2bsd on Saturday October 08, 2022 @05:08PM (#33136035)
> 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."

Re:Jq Internals: Backtracking (2017) by adammarples on Friday October 07, 2022 @10:46AM (#33122092)
Columnq is pretty amazing, fully SQL, you can even join them to CSV etc