Search results
/postroll
gron
github.com
gron
is a tool for working with JSON. It chunks things into key-value pairs where the key is a dot-separated hierarchy. This allows you then to use grep
or ack
to search for strings of interest.
It can also reassemble these back into JSON. This can be useful for adding or removing portions of a JSON structure. It becomes really interesting then when you pair it with jq
in order to retrieve data back out.
As an example, I can get the list of development requirements from a composer.json
with the following:
gron composer.json | ack "require-dev" | gron -u | jq '."require-dev" | keys[]'
(They'll still be in quotes, but that's easier to deal with than JSON keys!)
Search tips
- Use
#{some tag}
ortag:{some tag}
to filter by tag; using this more than once will find results that match all tags. - Use
year:{year}
to filter by year. If you use this multiple times, the last one wins. - Use
begin:{year-month-day}
to restrict to results beginning on that day. Last one wins. - Use
end:{year-month-day}
to restrict to results ending on that day. Last one wins.