Skip to content

Instantly share code, notes, and snippets.

@relwell
Created August 8, 2016 18:25
Show Gist options
  • Save relwell/31430523b696a7541097eb699ec6d192 to your computer and use it in GitHub Desktop.
Save relwell/31430523b696a7541097eb699ec6d192 to your computer and use it in GitHub Desktop.
2.1.5 :023 > a
=> {:test=>"one two three", :foo=>456262, :nested=>{:is=>"pretty hard with csvs, and regular expressions"}}
2.1.5 :024 > a.to_json
=> "{\"test\":\"one two three\",\"foo\":456262,\"nested\":{\"is\":\"pretty hard with csvs, and regular expressions\"}}"
2.1.5 :025 > b = Base64.encode64(a.to_json)
Base64.encode64
2.1.5 :025 > b = Base64.encode64(a.to_json)
=> "eyJ0ZXN0Ijoib25lIHR3byB0aHJlZSIsImZvbyI6NDU2MjYyLCJuZXN0ZWQi\nOnsiaXMiOiJwcmV0dHkgaGFyZCB3aXRoIGNzdnMsIGFuZCByZWd1bGFyIGV4\ncHJlc3Npb25zIn19\n"
2.1.5 :026 > Base64.decode64(b)
=> "{\"test\":\"one two three\",\"foo\":456262,\"nested\":{\"is\":\"pretty hard with csvs, and regular expressions\"}}"
2.1.5 :027 > JSON.parse(Base64.decode64(Base64.encode64(a.to_json)))
=> {"test"=>"one two three", "foo"=>456262, "nested"=>{"is"=>"pretty hard with csvs, and regular expressions"}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment