Skip to content

Instantly share code, notes, and snippets.

@keldin-coding
Last active November 6, 2021 07:43
Show Gist options
  • Save keldin-coding/e11cc6907c7a09c25ae830cf742c9527 to your computer and use it in GitHub Desktop.
Save keldin-coding/e11cc6907c7a09c25ae830cf742c9527 to your computer and use it in GitHub Desktop.
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