Skip to content

Commit

Permalink
cleanup prose and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
rsdoiel committed Jun 23, 2017
1 parent 95398e3 commit 1d45141
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 40 deletions.
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ bin/csvcols: datatools.go cmds/csvcols/csvcols.go
bin/csvjoin: datatools.go cmds/csvjoin/csvjoin.go
go build -o bin/csvjoin cmds/csvjoin/csvjoin.go

bin/jsoncols: datatools.go dotpath/dotpath.go cmds/jsoncols/jsoncols.go
bin/jsoncols: datatools.go cmds/jsoncols/jsoncols.go
go build -o bin/jsoncols cmds/jsoncols/jsoncols.go

bin/jsonrange: datatools.go dotpath/dotpath.go cmds/jsonrange/jsonrange.go
bin/jsonrange: datatools.go cmds/jsonrange/jsonrange.go
go build -o bin/jsonrange cmds/jsonrange/jsonrange.go

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


test:
cd dotpath && go test
go test

website:
Expand Down
2 changes: 1 addition & 1 deletion cmds/jsonrange/jsonrange.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func init() {
flag.StringVar(&delimiter, "d", "", "set delimiter for range output")
flag.StringVar(&delimiter, "delimiter", "", "set delimiter for range output")
flag.IntVar(&limit, "limit", 0, "limit the number of items output")
flag.BoolVar(&permissive, "permissive", false, "Suppress errors messages")
flag.BoolVar(&permissive, "permissive", false, "suppress errors messages")
}

func main() {
Expand Down
55 changes: 36 additions & 19 deletions docs/jsoncols.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@

# jsoncols

## USAGE
## USAGE:

jsoncols [OPTIONS] [EXPRESSION] [INPUT_FILENAME] [OUTPUT_FILENAME]

## SYSNOPSIS

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

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

```
-d set the delimiter for multi-field output
-h display help
-i read JSON from a file
-input read JSON from a file
-l display license
-m display output in monochrome
-r run interactively
-repl run interactively
-v display version
-d set the delimiter for multi-field output
-h display help
-i input filename
-input input filename
-l display license
-m display output in monochrome
-o output filename
-output output filename
-permissive suppress error messages
-r run interactively
-repl run interactively
-v display version
```


## EXAMPLES

If myblob.json contained
Expand All @@ -45,8 +48,8 @@ If myblob.json contained

Getting just the name could be done with

```
jsoncols .name myblob.json
```shell
jsoncols -i myblob.json .name
```

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

```
jsoncols -d\| ".name .age" myblob.json
```shell
jsoncols -i myblob.json -d\| .name .age
```

This would yeild
Expand All @@ -69,3 +72,17 @@ This would yeild
"Doe, Jane"|42
```

You can also pipe JSON data in.

```shell
cat myblob.json | jsoncols .name .email .age
```

Would yield

```
"Doe, Jane",[email protected],42
```


jsoncols v0.0.9
39 changes: 22 additions & 17 deletions docs/jsonrange.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,36 @@ select the parts of the JSON data structure you want from the range.
DOT_PATH_EXPRESSION is a dot path stale expression indicating what you want range over.
E.g.

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

The path can be chained together

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


## OPTIONS

```
-d set delimiter for range output
-d set delimiter for range output
-delimiter set delimiter for range output
-h display help
-i read JSON from file
-input read JSON from file
-l display license
-last return the index of the last element in list (e.g. length - 1)
-length return the number of keys or values
-limit limit the number of items output
-o write to output file
-output write to output file
-v display version
-values return the values instead of the keys
-h display help
-i read JSON from file
-input read JSON from file
-l display license
-last return the index of the last element in list (e.g. length - 1)
-length return the number of keys or values
-limit limit the number of items output
-o write to output file
-output write to output file
-permissive suppress errors messages
-v display version
-values return the values instead of the keys
```


## EXAMPLES

Working with a map
Expand Down Expand Up @@ -82,6 +85,7 @@ This would yield
42
```


Working with an array

```shell
Expand Down Expand Up @@ -147,3 +151,4 @@ would yield
2
```

jsonrange v0.0.9

0 comments on commit 1d45141

Please sign in to comment.