1
0

More than 1 year has passed since last update.

コマンドラインで Ruby を使って YAML <=> JSON の変換を行うワンライナー

Last updated at Posted at 2021-07-07

JSON => YAML

$ ruby -rjson -ryaml -e 'print JSON.load(STDIN.read).to_yaml' < foo.json

YAML => JSON

$ ruby -rjson -ryaml -e 'print YAML.load(STDIN.read).to_json' < foo.yml

YAML => JSON (pretty)

$ ruby -rjson -ryaml -e 'print JSON.pretty_generate(YAML.load(STDIN.read))' < foo.yml
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0