Created
September 6, 2013 22:16
-
-
Save sgzijl/6470712 to your computer and use it in GitHub Desktop.
datastructure to yaml & json (including a multiliner).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'yaml' | |
require 'json' | |
data = { | |
'somekey' => 'a value', | |
'another key' => [ 'an', 'array', 'of', 'values' ], | |
'multiliner key' => "line 1\n line 2\n line 3\n", | |
'a final key' => 'last value', | |
} | |
File.open('output.yaml', 'w') { |f| f.write data.to_yaml } | |
File.open('output.json', 'w') { |f| f.write data.to_json } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment