Created
June 24, 2019 15:41
-
-
Save evansd/55ad36f35c13fccfcd2e506e0c123730 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Converts JSON into a flat, line-by-line format | |
| # Equivalent to https://github.com/soheilpro/catj | |
| # Borrowed from this HN comment: https://news.ycombinator.com/item?id=20246957 | |
| exec jq -r ' | |
| tostream | |
| | select(length > 1) | |
| | ( | |
| .[0] | map( | |
| if type == "number" | |
| then "[" + tostring + "]" | |
| else "." + . | |
| end | |
| ) | join("") | |
| ) + " = " + (.[1] | @json) | |
| ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment