News for hackers. Stuff that matters.
Re:jq 1.7 released by cryptonector on Wednesday September 06, 2023 @10:08PM (#37413871)
You can trivially approximate gron with jq, and you there are jq implementations of gron too, like https://gist.github.com/mkfmnn/7b637aa0ec9b0422b3b75ec181a13...

E.g.,

  # gron
  gron "https://api.github.com/repos/tomnomnom/gron/commits?per_page=1" |
  fgrep commit.author
  json[0].commit.author = {};
  json[0].commit.author.date = "2016-07-02T10:51:21Z";
  json[0].commit.author.email = "[email protected]";
  json[0].commit.author.name = "Tom Hudson";

  # jq
  curl -L "https://api.github.com/repos/tomnomnom/gron/commits?per_page=1" |
  jq -r 'paths(scalars) as $p | getpath($p) | "\($p|join(".")|select(contains("commit.author"))) = \(.)"'
  0.commit.author.name = Tom Hudson
  0.commit.author.email = [email protected]
  0.commit.author.date = 2022-04-13T14:23:37Z

  # jq with grep outside jq
  curl -L "https://api.github.com/repos/tomnomnom/gron/commits?per_page=1" |
  jq -r 'paths(scalars) as $p | getpath($p) | "\($p|join(".")) = \(.)"' |
  fgrep commit.author
  0.commit.author.name = Tom Hudson
  0.commit.author.email = [email protected]
  0.commit.author.date = 2022-04-13T14:23:37Z
With just a bit more work you can get it to output valid gron, and even to parse valid gron.

There are no comments on this comment yet.