knowledge/technology/applications/cli/gron.md

1.8 KiB

obj repo rev
application https://github.com/tomnomnom/gron 2024-02-27

gron

gron transforms JSON into discrete assignments to make it easier to grep, ripgrep for what you want and see the absolute 'path' to it.

Usage

Transform JSON (from a file, URL, or stdin) into discrete assignments to make it greppable
Usage: gron [OPTIONS] [FILE|URL|-]

Options

Option Description
-u, --ungron Reverse the operation (turn assignments back into JSON)
-v, --values Print just the values of provided assignments
-c, --colorize Colorize output (default on tty)
-m, --monochrome Monochrome (don't colorize output)
-s, --stream Treat each line of input as a separate JSON object
-k, --insecure Disable certificate validation
-j, --json Represent gron data as JSON stream
--no-sort Don't sort output (faster)

Example

Gron turns the following json file:

{
    "key": "value",
    "num": 42,
    "b": true,
    "obj": {
        "sub": "key"
    },
    "lst": [1,2,3]
}

into this:

json = {};
json.b = true;
json.key = "value";
json.lst = [];
json.lst[0] = 1;
json.lst[1] = 2;
json.lst[2] = 3;
json.num = 42;
json.obj = {};
json.obj.sub = "key";