News for hackers. Stuff that matters.
Re:jq 1.7 released by VoodooJuJu on Thursday September 07, 2023 @07:28AM (#37417417)
Works well enough, but it really tripped me up at first with the syntax. Had to constantly look things up while using it.

  jq -r \
  '.apps.http.servers.srv1.routes[0]
  | .match[0].header.[env.AUTH_USER_HEADER][0] = "$username"'
That's an error because you can't select an env var key '[env.AUTH_USER_HEADER]' in the middle of a chain like that, only immediately following a pipe:

  | .match[0].header | .[env.AUTH_USER_HEADER][0] = "$username"'
But then I need to preserve the parent object after the assignment and that pipe throws it out. Thankfully, parentheses fix that:

  | (.match[0].header | .[env.AUTH_USER_HEADER][0]) = "$username"'
After working out the gotchas, it's quite powerful, like regex, but a little clunky, though not nearly as much as regex.
Re:jq 1.7 released by rewmie on Thursday September 07, 2023 @07:32AM (#37417446)
> Almost feels like I'm learning regex again.

But isn't that what jq is and always has been? I mean,what led you to believe that an entirely unrelated pattern matching language would work?

Re:jq 1.7 released by cryptonector on Thursday September 07, 2023 @09:45AM (#37418832)
> jq -r \ > '.apps.http.servers.srv1.routes[0] > | .match[0].header.[env.AUTH_USER_HEADER][0] = "$username"'

> That's an error because you can't select an env var key '[env.AUTH_USER_HEADER]' in the middle of a chain like that, only immediately following a pipe:

> | .match[0].header | .[env.AUTH_USER_HEADER][0] = "$username"'

You can use `env.AUTH_USER_HEADER` as a key the way you wanted. The issue is that you had to write `... | .match[0].header[env.AUTH_USER_HEADER] ...` -- no `.` between "header" and the index operator!

Re:jq 1.7 released by jpoprocks on Thursday September 07, 2023 @07:20PM (#37427030)
this was fixed in jq 1.7 :)