catj icon indicating copy to clipboard operation
catj copied to clipboard

jq script equivalent

Open allan-simon opened this issue 5 years ago • 2 comments

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 )

allan-simon avatar Jun 22 '19 09:06 allan-simon

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

incredimike avatar Jun 23 '19 17:06 incredimike

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

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

jackharrhy avatar Jun 24 '19 14:06 jackharrhy