improve man page and documentation + fix a typo in a comment - json2tsv - JSON … | |
git clone git://git.codemadness.org/json2tsv | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit baf6b755ae6ade6117900996c134a86b12ade3b6 | |
parent fea1a2013f259f23798d9a611f783f25b4f7448d | |
Author: Hiltjo Posthuma <[email protected]> | |
Date: Sat, 25 Sep 2021 11:38:28 +0200 | |
improve man page and documentation + fix a typo in a comment | |
Diffstat: | |
M README | 8 ++++---- | |
M json2tsv.1 | 16 +++++++++++----- | |
M json2tsv.c | 2 +- | |
3 files changed, 16 insertions(+), 10 deletions(-) | |
--- | |
diff --git a/README b/README | |
@@ -1,10 +1,10 @@ | |
json2tsv | |
-------- | |
-Convert JSON to TSV. | |
+Convert JSON to TSV or separated output. | |
json2tsv reads JSON data from stdin. It outputs each JSON type to a TAB- | |
-Separated Value format per line. | |
+Separated Value format per line by default. | |
Build and install | |
@@ -31,7 +31,7 @@ Optional dependencies | |
TAB-Separated Value format | |
-------------------------- | |
-The output format per line is: | |
+By default the output format per line is: | |
nodename<TAB>type<TAB>value<LF> | |
@@ -49,7 +49,7 @@ The type field is a single byte and can be: | |
Filtering on the first field "nodename" is easy using awk for example. | |
-See the json2tsv(1) man page for the full documentation. | |
+See the json2tsv(1) man page for the full documentation of the options. | |
Example | |
diff --git a/json2tsv.1 b/json2tsv.1 | |
@@ -1,9 +1,9 @@ | |
-.Dd September 24, 2021 | |
+.Dd September 25, 2021 | |
.Dt JSON2TSV 1 | |
.Os | |
.Sh NAME | |
.Nm json2tsv | |
-.Nd convert JSON to TSV | |
+.Nd convert JSON to TSV or separated output | |
.Sh SYNOPSIS | |
.Nm | |
.Op Fl n | |
@@ -32,7 +32,7 @@ Use | |
as the record separator. | |
The default is a newline character. | |
.El | |
-.Pp | |
+.Sh SEPARATOR CHARACTERS | |
The | |
.Ar fs | |
or | |
@@ -69,11 +69,14 @@ escaped in the nodename and value fields unless a | |
or | |
.Fl R | |
option is specified. | |
-When the .Fl F | |
+.Pp | |
+When the | |
+.Fl F | |
or | |
.Fl R | |
option is specified then the separator characters are removed from the output. | |
-Control-characters are removed, unless the option | |
+TABs or newlines are printed unless they are set as a separator. | |
+Other control-characters are removed, unless the option | |
.Fl r | |
is set. | |
.Pp | |
@@ -110,6 +113,9 @@ options can be used. | |
In the example below it uses the ASCII character 0x1f (Unit Separator) as the | |
field separator and the ASCII character 0x1e (Record Separator) as the record | |
separator. | |
+Additionally the | |
+.Fl r | |
+option is used so control-characters are printed. | |
.Bd -literal | |
json2tsv -r -F '\\x1f' -R '\\x1e' < input.json | \\ | |
awk ' | |
diff --git a/json2tsv.c b/json2tsv.c | |
@@ -59,7 +59,7 @@ rs_printvalue(const char *s) | |
} | |
} | |
-/* optimized printing an unsigned number (compared to printf("%zu"); */ | |
+/* optimized printing an unsigned number (compared to printf("%zu")) */ | |
void | |
printnum(uintmax_t x) | |
{ |