mirror of
https://github.com/mikefarah/yq.git
synced 2024-12-19 20:19:04 +00:00
yq is a portable command-line YAML, JSON, XML, CSV, TOML and properties processor
docs | ||
Godeps | ||
mkdocs | ||
.gitignore | ||
.travis.yml | ||
ci.sh | ||
data_navigator_test.go | ||
data_navigator.go | ||
instruction_sample.yaml | ||
json_converter_test.go | ||
json_converter.go | ||
LICENSE | ||
mkdocs.yml | ||
order.yaml | ||
order.yml | ||
path_parser_test.go | ||
path_parser.go | ||
precheckin.sh | ||
README.md | ||
release.sh | ||
sample2.yaml | ||
sample.json | ||
sample.yaml | ||
utils_test.go | ||
yaml_test.go | ||
yaml.go |
yaml
yaml is a lightweight and flexible command-line YAML processor
The aim of the project is to be the jq or sed of yaml files.
Install
Download latest binary or alternatively:
go get github.com/mikefarah/yaml
Features
- Written in portable go, so you can download a lovely dependency free binary
- Deep read a yaml file with a given path
- Update a yaml file given a path
- Update a yaml file given a script file
- Update creates any missing entries in the path on the fly
- Create a yaml file given a deep path and value
- Create a yaml file given a script file
- Convert from json to yaml
- Convert from yaml to json
- Pipe data in by using '-'
Usage
Check out the documentation for more detailed and advanced usage.
Read
yaml r <yaml file> <path>
Given a sample.yaml file of:
b:
c: 2
then
yaml r sample.yaml b.c
will output the value of '2'.
Update
Existing yaml files can be updated via the write command
Given a sample.yaml file of:
b:
c: 2
then
yaml w sample.yaml b.c cat
will output:
b:
c: cat
Create
Yaml files can be created using the 'new' command. This works in the same way as the write command, but you don't pass in an existing Yaml file.
Creating a simple yaml file
yaml n b.c cat
will output:
b:
c: cat
Converting to and from json
Yaml2json
To convert output to json, use the --tojson (or -j) flag. This can be used with any command.
json2yaml
To read in json, use the --fromjson (or -J) flag. This can be used with any command.