Skip to content

Instantly share code, notes, and snippets.

@egoens
Created May 11, 2016 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save egoens/d34660e2be399c257941da0447565385 to your computer and use it in GitHub Desktop.
Save egoens/d34660e2be399c257941da0447565385 to your computer and use it in GitHub Desktop.
YML to JSON
# as file yml_to_json.rb
require 'yaml'
require 'json'
output = File.open('new_file_name.json','w')
output << JSON.pretty_generate(YAML.load_file('./yaml_file.yml'))
output.close
# one liner
ruby -e "require 'yaml';require 'json';output = File.open('new_file_name.json','w');output << JSON.pretty_generate(YAML.load_file('./yaml_file.yml'));output.close"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment