3 ms·
Have you tried `gron`? It converts your nested json into a line by line format which plays better with tools like `grep` From the project's README: ▶ gron "h
by ishandotpage 3y ago
Have you tried `gron`?
It converts your nested json into a line by line format which plays better with tools like `grep`
From the project's README:
▶ gron "https://api.github.com/repos/tomnomnom/gron/commits?per_page=1 https://api.github.com/repos/tomnomnom/gron/commits?per_page..." | fgrep "commit.author"
json[0].commit.author = {};
json[0].commit.author.date = "2016-07-02T10:51:21Z";
json[0].commit.author.email = "mail@tomnomnom.com";
json[0].commit.author.name = "Tom Hudson";
https://github.com/tomnomnom/gron https://github.com/tomnomnom/gron
It was suggested to me in HN comments on an article I wrote about `jq`, and I have found myself using it a lot in my day to day workflow
- hu3 3y agoThank you so much. This seems like a saner approach for some simpler use cases. It flattens the structure. And makes for easy diffing.
- evntdrvn 3y agoThere's also this awesome tool to make JSON interactively navigable in the terminal: https://fx.wtf https://fx.wtf
- sn0wf1re 3y agoYou can also mimic gron, including support for yaml with yq -o=props my-file.yaml
- majewsky 3y agoDoesn't work in my terminal. When you recommend yq behavior, please specify which yq you're using. There are at least two incompatible implementations.
- stronglikedan 3y agoThis is awesome, thanks! Not OP, but this will help me to write specifications for modifying existing JSON structures immensely. It's kind of a pain parsing JSON by (old man) eye to figure out which properties are arrays, and follow property names down a chain. This will definitely help eliminate mistakes!
- pdimitar 3y agoAlso try jless[0], it's amazingly convenient and it shows you a JSON path at the bottom of the screen as you navigate. [0] https://jless.io/ https://jless.io/
- jbverschoor 3y agoThis looks some much better as an ad-hoc tool. Would be cool if it supported more formats - plist, yaml, xml (hoow to do body, or conflicting attr/elements)