Expand description
§dts
A simple tool to deserialize data from an input encoding, transform it and serialize it back into an output encoding.
Uses jq for data transformation and
requires rust >= 1.56.0.
§Installation
Check out the releases page
for prebuilt versions of dts.
Statically-linked binaries are also available: look for archives with musl in
the filename.
§From crates.io
cargo install dts§From source
Clone the repository and run:
cargo install --locked --path .§Usage
dts [<source>...] [-j <jq-expression>] [-O <sink>...]For a full list of available flags consult the help:
dts --help§Examples
Convert YAML to TOML:
dts input.yaml -o tomlLoad all YAML files from sub directories and merge them into one:
dts . --glob '**/*.yaml' output.yamlTransform the input data using a jq expression:
dts tests/fixtures/example.json -j '.users | map(select(.age < 30))'Use jq filter expression from a file:
dts tests/fixtures/example.json -j @my-filter.jqRead data from stdin:
echo '{"foo": {"bar": "baz"}}' | dts -i json -o yaml§Output colors and themes
dts supports output coloring and syntax highlighting. The coloring behaviour
can be controlled via the --color flag or DTS_COLOR environment variable.
If the default theme used for syntax highlighting does not suit you, you can
change it via the --theme flag or DTS_THEME environment variable.
Available themes can be listed via:
dts --list-themesHint: The color feature can be disabled at compile time if you don’t want
to have colors at all. See the feature flags section below.
§Supported Encodings
Right now dts supports the following encodings:
- JSON
- YAML
- TOML
- JSON5 (deserialize only)
- CSV
- QueryString
- XML
- Text
- Gron
- HCL (deserialize, serialize only supports HCL attributes)
§Feature flags
To build dts without its default features enabled, run:
cargo build --no-default-features --releaseThe following feature flags are available:
-
color: Enables support for colored output. This feature is enabled by default.If you just want to disable colors by default with the option to enable them conditionally, you can also set the
NO_COLORenvironment variable or setDTS_COLOR=never. -
jaq: Usejaq-coreto process transformation filters instead of shelling out tojq. This feature is enabled by default.
§License
The source code of dts is released under the MIT License. See the bundled LICENSE file for details.
Modules§
- de
- This module provides a
Deserializerwhich supports deserializing input data with various encodings into aValue. - filter
- Provides functionality to filter a
serde_json::Valuebased on a filter expression. - key
- Object key transformation utilities.
- ser
- This module provides a
Serializerwhich supports serializing values into various output encodings.
Structs§
- Source
Reader - A type that can read from a
Source. It is able to detect theSource’s encoding by looking at the first line of the input.
Enums§
- Encoding
- Encodings supported by this crate.
- Error
- The error returned by all fallible operations within this crate.
- Sink
- A target to write serialized output to.
- Source
- A source for data that needs to be deserialized.
Type Aliases§
- Result
- A type alias for
Result<T, Error>.