Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jq script equivalent #1

Open
allan-simon opened this issue Jun 22, 2019 · 2 comments
Open

jq script equivalent #1

allan-simon opened this issue Jun 22, 2019 · 2 comments

Comments

@allan-simon
Copy link

copy pasted from : https://news.ycombinator.com/item?id=20246727

  #!/usr/bin/jq -jf
  jq -j '
    [
      [
        paths(scalars)
        | map(
          if type == "number"
          then "[" + tostring + "]"
          else "." + .
          end
        ) | join("")
      ],
      [
        .. | select(scalars) | @json
      ]
    ]
    | transpose
    | map(join(" = ") + "\n")
    | join("") 
  '

(just so that if somebody come accross your great project, and wants to do something equivalent without needing npm )

@incredimike
Copy link

For those reading this, check the Hacker News thread link above for updated, improved versions of this code.

@jackharrhy
Copy link

gron also looks good for this usecase: https://github.com/tomnomnom/gron

i'm also gonna plug my own: https://github.com/jackharrhy/meowj

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants