4 ms·
i dont know if i'd call its syntax bloated at all. jq is something i've hated learning but powerful beyond tying grep and awk together. jq is a tool, and like
by sigmonsays 6y ago
i dont know if i'd call its syntax bloated at all.
jq is something i've hated learning but powerful beyond tying grep and awk together.
jq is a tool, and like every tool, requires some upfront learning. Once mastered its much more productive than the grep/awk/friends solution.
Take this example JSON
<pre>
{ "code": 42,
"items": [
{ "type":"color", "name":"red", "rgb": [120, 2, 2 ]},
{ "type":"color", "name":"green", "rgb": [2, 120, 2]}
]
}
</pre>
for instance, to grab the rgb field for the color green...
jq -r '.items | .[] | select(.name=="green") | .rgb
- benibela 6y agoAn alternative would be to use XPath 3.1. I am implementing XPath in a tool called Xidel. There the syntax for the example is much simpler: xidel - -e '?items ?* [?name="green"] ?rgb' Depends what kabacha means with bloated. The XPath syntax is more verbose, but less cryptic