11
\$\begingroup\$

In accordance with our meta agreement, since one candidate received more votes than the others, we have a new featured language! Throughout September 2021, our Language of the Month will be:

jq

What's a Language of the Month?

See the meta post for nominations. In short, during September, those who wish to participate should learn jq, and use it to solve challenges.

Information about jq

jq is a lightweight practical language for querying JSON files. It's like sed for JSON files.

  • Streams in jq can be very powerful. Operators see individual items in strings when applied:
range(4) -> 0, 1, 2, 3
range(4) + 2 -> 1, 2, 3, 4

# Sometimes, a cartesian-product-like output can be produced with

range(2) + range(4) -> 0,1, 1,2, 2,3, 3,4
  • Piping - Outputs of the previous expression can be piped.
3 | .+2  #  -> 5

[3, 4, 5] | max   # -> 5
  • Compact syntax
[1, 2, 3] | map( . + 1 ) # -> [2, 3, 4]

# (This could also be achieved as [1, 2, 3][]|.+1)

Bounty

I (Emanresu A, or whatever I end up changing my name to) will award a +50 bounty for any user's first jq answer posted during this month. A user doesn't qualify if they have posted a jq answer before.

I will only award this bounty on questions which I haven't answered, because I have to award +100 or more on questions which I have. If the question you answered has been answered by me as well, provide another jq answer and I'll happily bounty that.

Resources

\$\endgroup\$
5
  • 1
    \$\begingroup\$ Your last example can be golfed even further with 1,2,3|.+1! Try it online \$\endgroup\$
    – AviFS
    Sep 2 at 5:32
  • 1
    \$\begingroup\$ range(4)+2 should be 2,3,4,5 \$\endgroup\$
    – MarcMush
    Sep 8 at 9:59
  • \$\begingroup\$ is there going to be a jq chat room? \$\endgroup\$ Sep 9 at 11:34
  • \$\begingroup\$ @Wezl There is now! \$\endgroup\$
    – DLosc
    Sep 9 at 16:39
  • \$\begingroup\$ Well, there was, but nobody used it. :( \$\endgroup\$
    – DLosc
    Sep 23 at 20:47
3
\$\begingroup\$

List of all jq solutions posted in September 2021

First-time answerers highlighted in bold, bounty requests in italic. For bounty requests, I can't award it if I've bountied the question already or answered it already.


List of all jq tips posted in September 2021

  • Use try-// instead of if-then-else by ovs

  • add entries in the form:

      [<tip title>](https://codegolf.stackexchange.com/a/<answer-ID>) by [username](https://codegolf.stackexchange.com/users/<user-ID>)
    

List of jq-related challenges posted in September 2021

  • add entries in the form:

      [<challenge title>](https://codegolf.stackexchange.com/q/<question-ID>) by [username](https://codegolf.stackexchange.com/users/<user-ID>)
    
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .