Skip to content

Instantly share code, notes, and snippets.

@keithrbennett
Created June 17, 2014 20:09
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 keithrbennett/77d2ab5512f7d9b7a286 to your computer and use it in GitHub Desktop.
Save keithrbennett/77d2ab5512f7d9b7a286 to your computer and use it in GitHub Desktop.
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