Created
January 1, 2013 01:31
-
-
Save acook/4424574 to your computer and use it in GitHub Desktop.
Quick comparison of YAML, JSON, and BSON. Results were.. inconclusive. O_o
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
1.9.3> require 'bson' | |
=> true | |
1.9.3> require 'json' | |
=> true | |
1.9.3> require 'yaml' | |
=> true | |
1.9.3> h = {foo: 'bar'} | |
=> {:foo=>"bar"} | |
1.9.3> b = BSON.serialize h | |
=> foobar | |
1.9.3> b.inspect | |
=> "\x12\x00\x00\x00\x02foo\x00\x04\x00\x00\x00bar\x00\x00" | |
1.9.3> j = h.to_json | |
=> "{\"foo\":\"bar\"}" | |
1.9.3> y = h.to_yaml | |
=> "---\n:foo: bar\n" | |
1.9.3> j.length | |
=> 13 | |
1.9.3> b.length | |
=> 18 | |
1.9.3> y.length | |
=> 14 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment