Caltech Library logo

USAGE

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

DESCRIPTION

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.

OPTIONS

Below are a set of options available.

    -csv                 output as CSV or other flat delimiter row
    -d, -delimiter       set the delimiter for multi-field csv output
    -examples            display example(s)
    -generate-manpage    generate man page
    -generate-markdown   generate markdown documentation
    -h, -help            display help
    -i, -input           input filename
    -l, -license         display license
    -nl, -newline        if true add a trailing newline
    -o, -output          output filename
    -p, -pretty          pretty print JSON output
    -quiet               suppress error messages
    -quote               quote strings and JSON notation
    -r                   run interactively
    -repl                run interactively
    -v, -version         display version

EXAMPLES

If myblob.json contained

{"name": "Doe, Jane", "email":"jane.doe@example.org", "age": 42}

Getting just the name could be done with

jsoncols -i myblob.json .name

This would yield

"Doe, Jane"

Flipping .name and .age into pipe delimited columns is as easy as listing each field in the expression inside a space delimited string.

jsoncols -i myblob.json -d\|  .name .age

This would yield

Doe, Jane|42

You can also pipe JSON data in.

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

Would yield

“Doe, Jane”,“jane.doe@xample.org”,42

jsoncols v0.0.25