News for hackers. Stuff that matters.
Re:Illustrated Jq Tutorial by wonginator1221 on Thursday March 19, 2020 @12:16PM (#22628898)
Nice! I struggled to learn jq initially and I made a similar page for my team.

One suggestion is to use with_entries as a replacement for the 'to_entries | map(...) | from_entries' pattern. For example:

  jq '.metadata.annotations | with_entries(select(.key == "label1"))'
is equivalent to

  jq '.metadata.annotations | to_entries | map(select(.key == "label1")) | from_entries'
Re:Illustrated Jq Tutorial by philsnow on Thursday March 19, 2020 @08:57PM (#22633466)
Not related to with_entries, but I didn't see anywhere else in this thread that mentioned dealing with awscli output

from_entries handles nicely the Tags in a lot of awscli output, you can do things like

    aws ec2 describe-instances | \
        jq '.Reservations[].Instances[] | 
            {Role: .Tags | from_entries | .role,
             Name: .Tags | from_entries | .name,
             Id: .InstanceId}' \
        -C -c | sort | less -R
to get a summary of all your instances sorted by role.
Re:Illustrated Jq Tutorial by MichaelMoser123 on Thursday March 19, 2020 @12:30PM (#22629054)
thanks for the suggestion, i will add another example like this.