Skip to content

YAML-to-JSON and JSON-to-YAML conversion #238

Answered by TomWright
electriquo asked this question in Q&A
Discussion options

You must be logged in to vote

This is already possible using the -r,--read and -w,--write flags. You can read more on them here: https://daseldocs.tomwright.me/usage/select

$ echo 'foo: bar' | dasel -r yaml -w json -c
{"foo":"bar"}

$ echo 'foo: bar' | dasel -r yaml -w toml
foo = "bar"

$ echo 'foo: bar' | dasel -r yaml -w json | dasel -r json -w yaml
foo: bar

$ echo '<users><user><name>Tom</name></user><user><name>Jim</name></user></users>' | dasel -r xml -w yaml
users:
  user:
  - name: Tom
  - name: Jim

The supported file types can be found here: https://daseldocs.tomwright.me/usage/supported-file-types

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by TomWright
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants