#data #cli #jyx #unstructured

app jyx

Command line tool for manipulating data structures

3 unstable releases

✓ Uses Rust 2018 edition

0.3.1 Aug 25, 2019
0.3.0 Aug 25, 2019
0.2.0 May 17, 2019

#224 in Data structures

MIT license

96KB
2K SLoC

Crate Documentation MIT License

jyx CLI

jyx is a CLI tool for manipulating data of various formats. It is useful for converting between various formats and filtering data ingested by any of the supported formats.

Usage

jyx allows merging and filtering of any arbitrary number of inputs. One input source may be from stdin with an input format specified, which, when used, will be sourced as the document at index 0 for filtering purposes.

Command line tool for manipulating data structures

USAGE:
    jyx [OPTIONS]

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
    -f, --filter <filter>                Input filter
    -i, --input <inputs>...              Input files
    -o, --output <output-file>           Output file to write if not stdout
        --format <output-format>         The format of the generated output. [default: PrettyJson]  [possible values:
                                         PrettyJson, Json, Yaml, Toml, Xml]
    -s, --stdin-format <stdin-format>    The format of stdin input. [possible values: PrettyJson, Json, Yaml, Toml, Xml]

Examples

# This will print the combined result of both files to stdout
jyx -i input1.json -i input2.yaml

# Write to file instead of stdout
jyx -i input1.json -o output.json

# Convert to yaml
jyx -i input1.json -o output.yaml --format yaml

# Merge two files, write output to a yaml file, filter inputs to pull only selected fields
jyx -i Cargo.toml -i input2.json -o result.yaml --format yaml -f '[0].dependencies | [1].someData'

# Send request to XML API, convert output to JSON
curl https://raw.githubusercontent.com/danyork/sample-xml-files/master/helloworld.xml | jyx -s xml

Filters

The filter syntax is inspired by jq, another great tool, but also supports JSON Pointer syntax.

# Only print the key "key" in the first input document
jyx -f [0].key

# Print the first five element in the array "array" of the first input document
jyx -f [0].array.[:5]

# Print the key "key" from the first document and elements 5-10 of the array "array" from the second document
jyx -f '[0].["key"] | [1].array.[5:10]'
# Map keys can be accessed with any of the following syntaxes: .key .["key"] /key
# Specific array indexes can be accessed with an index identifier: .key.[1]
# Alternatively, keep that index in an array: .key.[1:1]
# Array ranges are open ended on either side: .key.[:5] .key.[5:] .key.[:]
# When merging documents, later values will take precedence over earlier values. Any collision in [1].key will overwrite [0].key here: [0].key | [1].key

Dependencies

~4.5MB
~84K SLoC