Created
June 17, 2014 20:09
-
-
Save keithrbennett/77d2ab5512f7d9b7a286 to your computer and use it in GitHub Desktop.
Shows how YAML generates back references and JSON does not
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
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