API
Gron's command line interface (CLI).
Attributes:
| Name | Type | Description |
|---|---|---|
parser |
ArgumentParser
|
|
main()
Gron's CLI.
This method reads the arguments for the command line interface and
runs gron.
Source code in gron/__main__.py
30 31 32 33 34 35 36 37 38 39 | |
Gron's core functions.
convert(name)
Convert path name into valid JSON.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
a path name |
required |
Returns:
| Type | Description |
|---|---|
str
|
valid JSON path |
Source code in gron/gron.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
gron(input_)
Transform JSON into parseable str.
This method takes a JSON string and transforms it into a grepable equivalent form.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_ |
str
|
JSON |
required |
Returns:
| Type | Description |
|---|---|
str
|
Transformed output |
Source code in gron/gron.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
walk(node, name)
Translate Python element to JSON.
This method recursively visits each element of a Python object and returns the JSON representation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node |
Any
|
A python object (e.g. dict, list, int, etc) |
required |
name |
str
|
The name (i.e. path) of the parent element |
required |
Returns:
| Type | Description |
|---|---|
str
|
Transformed JSON for this element |
Source code in gron/gron.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |