Last active
November 6, 2021 07:43
-
-
Save keldin-coding/e11cc6907c7a09c25ae830cf742c9527 to your computer and use it in GitHub Desktop.
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
require "yaml" | |
require "json" | |
str = <<~DOC | |
{ | |
"banana": "dog", | |
# We can do the thing | |
"aardvark": [ | |
1, 2, # we need the next | |
3, | |
4, | |
5 | |
] | |
} | |
DOC | |
data = YAML.load(str) | |
puts JSON.dump(data) | |
# $ ./ruby yaml_json.rb | |
# {"banana":"dog","aardvark":[1,2,3,4,5]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment