I hadn't seen jc before (by the author of this piece: https://github.com/kellyjonbrazil/jc ) - what a great idea! It has parsers for around 80 different classic Unix utilities such that it can convert their output to JSON.
~ % dig example.com | jc --dig | jq
[
{
"id": 61315,
"opcode": "QUERY",
"status": "NOERROR",
"flags": [
"qr",
"rd",
"ra"
],
"query_num": 1,
"answer_num": 1,
"authority_num": 0,
"additional_num": 1,
"opt_pseudosection": {
"edns": {
"version": 0,
"flags": [],
"udp": 512
}
},
"question": {
"name": "example.com.",
"class": "IN",
"type": "A"
},
"answer": [
{
"name": "example.com.",
"class": "IN",
"type": "A",
"ttl": 85586,
"data": "93.184.216.34"
}
],
"query_time": 29,
"server": "10.0.0.1#53(10.0.0.1)",
"when": "Sun Dec 05 15:12:08 PST 2021",
"rcvd": 56,
"when_epoch": 1638745928,
"when_epoch_utc": null
}
]
Turns out I can cross out a todo item off my list, because I wanted to make exactly the same thing.
Now, to find a query tool with a saner language than Jq...
What kind of thing are you trying to do?
jq can get pretty deep but for most things in this area I'm not sure how it could improve upon, but would be interested in hearing alternatives.
https://github.com/fiatjaf/jiq
Is a realtime feedback wrapper which I find useful when crafting one-off command line uses for jq and it starts getting crazy.
I actually collected a sizable list of alternatives to Jq:
https://github.com/TomConlin/json2xpath
https://github.com/antonmedv/fx
https://github.com/jmespath/jp
https://github.com/borkdude/jet
https://github.com/jzelinskie/faq
https://github.com/dflemstr/rq
And there's someone else's list of stuff around Jq: https://github.com/fiatjaf/awesome-jq
However, personally I think that next time I might instead fire up Hy, and use the regular syntax with the functional approach for any convoluted processing I come up with. Last time I mentioned this, another HNer made a Jq-like tool with Lisp-like syntax: https://github.com/cube2222/jql (from https://news.ycombinator.com/item?id=21981158).