Skip to content

Instantly share code, notes, and snippets.

@acook
Created January 1, 2013 01:31
Show Gist options
  • Save acook/4424574 to your computer and use it in GitHub Desktop.
Save acook/4424574 to your computer and use it in GitHub Desktop.
Quick comparison of YAML, JSON, and BSON. Results were.. inconclusive. O_o
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