Example in Guide to Linux jq Command for JSON Processing

The last example in the Guide to Linux jq Command for JSON Processing, which is one of the recommended jq reading material, uses the command:

jq '.query.pages | [.[] | map(.) | .[] | {page_title: .title, page_description: .extract}]' wikipedia.json

Turns out it can be simplified:

jq '.query.pages | [.[][] | {page_title: .title, page_description: .extract}]' wikipedia.json

Thought this is interesting.

1 Like

Sounds about right. It brings to mind the bash factoid for google. Most the shell scripting material on there on the internet is terrible. Even there half decent material out there tends to be only half decent. It’s quite hard to find really high quality material. Most people that write shell or jq material know the subject well enough to make things work, and that’s about it. They typically don’t have someone else reviewing their work or nit picking their commands to ensure it’s clean and optimal.

In contrast, I find the concept materials of the jq track not only of high quality but also very readable. Kudo to glennj.

Fantastic work!

1 Like

btw, there is a minor typo at the “Vehicle Purchase” exercise on the jq track:

It takes the an object holding the original price and the age of the vehicle and returns the estimated price in the dealership.

should probably have the spurious “the” removed:

It takes an object holding the original price and the age of the vehicle and returns the estimated price in the dealership.

Care to submit a PR for that? :smile: