A tiny CLI to covert JSON/YAML.
Many thanks to ghodss/yaml.
Multi platform binaries are available.
Put the downloaded/built binary to one of your $PATH
directories.
NAME:
j2y - convert JSON to YAML
USAGE:
j2y [global options] command [command options] [arguments...]
VERSION:
0.0.1
COMMANDS:
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--output, -o "STDOUT" path of output destination file path
--eval, -e treat argument as raw data instead of file path
--reverse, -r convert YAML to JSON
--minify, -m output JSON in single line format
--help, -h show help
--version, -v print the version
Example JSON from JSON Tutorial.
$ cat example.json
{"employees":[
{"firstName":"John", "lastName":"Doe"},
{"firstName":"Anna", "lastName":"Smith"},
{"firstName":"Peter", "lastName":"Jones"}
]}
$ j2y example.json
employees:
- firstName: John
lastName: Doe
- firstName: Anna
lastName: Smith
- firstName: Peter
lastName: Jones
$ j2y -o example.yml example.json
$ cat example.yml
employees:
- firstName: John
lastName: Doe
- firstName: Anna
lastName: Smith
- firstName: Peter
lastName: Jones
$ j2y -r example.yml
{
"employees": [
{
"firstName": "John",
"lastName": "Doe"
},
{
"firstName": "Anna",
"lastName": "Smith"
},
{
"firstName": "Peter",
"lastName": "Jones"
}
]
}
$ j2y -r -m example.yml
{"employees":[{"firstName":"John","lastName":"Doe"},{"firstName":"Anna","lastName":"Smith"},{"firstName":"Peter","lastName":"Jones"}]}
$ j2y -e '{"employees":[{"firstName":"John","lastName":"Doe"},{"firstName":"Anna","lastName":"Smith"},{"firstName":"Peter","lastName":"Jones"}]}'
employees:
- firstName: John
lastName: Doe
- firstName: Anna
lastName: Smith
- firstName: Peter
lastName: Jones
$ echo '{"employees":[{"firstName":"John","lastName":"Doe"},{"firstName":"Anna","lastName":"Smith"},{"firstName":"Peter","lastName":"Jones"}]}' | j2y
employees:
- firstName: John
lastName: Doe
- firstName: Anna
lastName: Smith
- firstName: Peter
lastName: Jones