Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Shows how YAML generates back references and JSON does not
2.1.2 :010 > h = { fruit: 'mango' }
=> {:fruit=>"mango"}
2.1.2 :011 > a = [h, h]
=> [{:fruit=>"mango"}, {:fruit=>"mango"}]
2.1.2 :013 > puts a.to_yaml
---
- &1
:fruit: mango
- *1
=> nil
2.1.2 :014 > puts JSON::pretty_generate(a)
[
{
"fruit": "mango"
},
{
"fruit": "mango"
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.