jq script equivalent
allan-simon opened this issue · 2 comments
allan-simon commented
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 commented
For those reading this, check the Hacker News thread link above for updated, improved versions of this code.
jackharrhy commented
gron also looks good for this usecase: https://github.com/tomnomnom/gron
i'm also gonna plug my own: https://github.com/jackharrhy/meowj