Skip to content

Commit 1d45141

Browse files
committed
cleanup prose and docs
1 parent 95398e3 commit 1d45141

File tree

4 files changed

+61
-40
lines changed

4 files changed

+61
-40
lines changed

Makefile

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ bin/csvcols: datatools.go cmds/csvcols/csvcols.go
1515
bin/csvjoin: datatools.go cmds/csvjoin/csvjoin.go
1616
go build -o bin/csvjoin cmds/csvjoin/csvjoin.go
1717

18-
bin/jsoncols: datatools.go dotpath/dotpath.go cmds/jsoncols/jsoncols.go
18+
bin/jsoncols: datatools.go cmds/jsoncols/jsoncols.go
1919
go build -o bin/jsoncols cmds/jsoncols/jsoncols.go
2020

21-
bin/jsonrange: datatools.go dotpath/dotpath.go cmds/jsonrange/jsonrange.go
21+
bin/jsonrange: datatools.go cmds/jsonrange/jsonrange.go
2222
go build -o bin/jsonrange cmds/jsonrange/jsonrange.go
2323

2424
bin/xlsx2json: datatools.go cmds/xlsx2json/xlsx2json.go
@@ -41,7 +41,6 @@ bin/csvfind: datatools.go cmds/csvfind/csvfind.go
4141

4242

4343
test:
44-
cd dotpath && go test
4544
go test
4645

4746
website:

cmds/jsonrange/jsonrange.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ func init() {
243243
flag.StringVar(&delimiter, "d", "", "set delimiter for range output")
244244
flag.StringVar(&delimiter, "delimiter", "", "set delimiter for range output")
245245
flag.IntVar(&limit, "limit", 0, "limit the number of items output")
246-
flag.BoolVar(&permissive, "permissive", false, "Suppress errors messages")
246+
flag.BoolVar(&permissive, "permissive", false, "suppress errors messages")
247247
}
248248

249249
func main() {

docs/jsoncols.md

+36-19
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11

22
# jsoncols
33

4-
## USAGE
4+
## USAGE:
55

66
jsoncols [OPTIONS] [EXPRESSION] [INPUT_FILENAME] [OUTPUT_FILENAME]
77

88
## SYSNOPSIS
99

10-
jsoncols provides for both interactive exploration of JSON structures like jid
11-
and command line scripting flexibility for data extraction into delimited
12-
columns. This is helpful in flattening content extracted from JSON blobs.
13-
The default delimiter for each value extracted is a comma. This can be
14-
overridden with an option.
10+
jsoncols provides scripting flexibility for data extraction from JSON data
11+
returning the results in columns. This is helpful in flattening content
12+
extracted from JSON blobs. The default delimiter for each value
13+
extracted is a comma. This can be overridden with an option.
1514

1615
+ EXPRESSION can be an empty stirng or dot notation for an object's path
1716
+ INPUT_FILENAME is the filename to read or a dash "-" if you want to
@@ -24,17 +23,21 @@ overridden with an option.
2423
## OPTIONS
2524

2625
```
27-
-d set the delimiter for multi-field output
28-
-h display help
29-
-i read JSON from a file
30-
-input read JSON from a file
31-
-l display license
32-
-m display output in monochrome
33-
-r run interactively
34-
-repl run interactively
35-
-v display version
26+
-d set the delimiter for multi-field output
27+
-h display help
28+
-i input filename
29+
-input input filename
30+
-l display license
31+
-m display output in monochrome
32+
-o output filename
33+
-output output filename
34+
-permissive suppress error messages
35+
-r run interactively
36+
-repl run interactively
37+
-v display version
3638
```
3739

40+
3841
## EXAMPLES
3942

4043
If myblob.json contained
@@ -45,8 +48,8 @@ If myblob.json contained
4548

4649
Getting just the name could be done with
4750

48-
```
49-
jsoncols .name myblob.json
51+
```shell
52+
jsoncols -i myblob.json .name
5053
```
5154

5255
This would yeild
@@ -59,8 +62,8 @@ Flipping .name and .age into pipe delimited columns is as
5962
easy as listing each field in the expression inside a
6063
space delimited string.
6164

62-
```
63-
jsoncols -d\| ".name .age" myblob.json
65+
```shell
66+
jsoncols -i myblob.json -d\| .name .age
6467
```
6568

6669
This would yeild
@@ -69,3 +72,17 @@ This would yeild
6972
"Doe, Jane"|42
7073
```
7174

75+
You can also pipe JSON data in.
76+
77+
```shell
78+
cat myblob.json | jsoncols .name .email .age
79+
```
80+
81+
Would yield
82+
83+
```
84+
"Doe, Jane",[email protected],42
85+
```
86+
87+
88+
jsoncols v0.0.9

docs/jsonrange.md

+22-17
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,36 @@ select the parts of the JSON data structure you want from the range.
2323
DOT_PATH_EXPRESSION is a dot path stale expression indicating what you want range over.
2424
E.g.
2525

26-
+ _._ would indicate the whole JSON data structure read is used to range over
27-
+ _.name_ would indicate to range over the value pointed at by the "name" attribute
28-
+ _["name"]_ would indicate to range over the value pointed at by the "name" attribute
29-
+ _[0]_ would indicate to range over the value held in the zero-th element of the array
26+
+ . would indicate the whole JSON data structure read is used to range over
27+
+ .name would indicate to range over the value pointed at by the "name" attribute
28+
+ ["name"] would indicate to range over the value pointed at by the "name" attribute
29+
+ [0] would indicate to range over the value held in the zero-th element of the array
3030

3131
The path can be chained together
3232

33-
+ _.name.family_ would point to the value heald by the "name" attributes' "family" attribute.
33+
+ .name.family would point to the value heald by the "name" attributes' "family" attribute.
34+
3435

3536
## OPTIONS
3637

3738
```
38-
-d set delimiter for range output
39+
-d set delimiter for range output
3940
-delimiter set delimiter for range output
40-
-h display help
41-
-i read JSON from file
42-
-input read JSON from file
43-
-l display license
44-
-last return the index of the last element in list (e.g. length - 1)
45-
-length return the number of keys or values
46-
-limit limit the number of items output
47-
-o write to output file
48-
-output write to output file
49-
-v display version
50-
-values return the values instead of the keys
41+
-h display help
42+
-i read JSON from file
43+
-input read JSON from file
44+
-l display license
45+
-last return the index of the last element in list (e.g. length - 1)
46+
-length return the number of keys or values
47+
-limit limit the number of items output
48+
-o write to output file
49+
-output write to output file
50+
-permissive suppress errors messages
51+
-v display version
52+
-values return the values instead of the keys
5153
```
5254

55+
5356
## EXAMPLES
5457

5558
Working with a map
@@ -82,6 +85,7 @@ This would yield
8285
42
8386
```
8487

88+
8589
Working with an array
8690

8791
```shell
@@ -147,3 +151,4 @@ would yield
147151
2
148152
```
149153

154+
jsonrange v0.0.9

0 commit comments

Comments
 (0)