Hacker News new | past | comments | ask | show | jobs | submit login

A bit OT:

The post links to the tutorial "An Introduction to JQ" at [1].

Somewhere inside the tutorial, array operators are introduced like this:

> jq lets you select the whole array [], a specific element [3], or ranges [2:5] and combine these with the object index if needed.

This is not supposed to be criticism on this particular tutorial (I've seen this kind of description quite often), but I could imagine this to be a typical "eyes glaze over" moment, where people subtly lose track of what is happening.

It appears to make sense on first glance, but leaves open the question what "selecting the whole array" actually means - especially, since you can write both ".myarray" and ".myarray[]" and both will select the whole array in a sense.

I think this is the point where one would really need to learn about sequences and about jq's processing model to not get frustrated later.

[1] https://earthly.dev/blog/jq-select/




Oh, I wrote that. I think I get what you mean. There are two different things, and they aren't being delineated. How would you explain it?

I don't know how jq works internally and in my mental model [] maps into the json array and also can wrap things back into an array. So that [.[]] unwraps and then rewraps a JSON array, sort of like how [.[].title] is the same as map(.title).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: