Created
February 22, 2020 02:48
-
-
Save tagomoris/8981fb5173a986bb837622a6039e4939 to your computer and use it in GitHub Desktop.
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
require 'msgpack' | |
# x = "\x82\xA9condition\xA2OR\xA6groups\x92\x82\xA9condition\xA2or\xA7filters\x91\x83\xA3col\xAAbirth_date\x | |
# A3ope\xA5month\xA3val\xA12\x82\xA9condition\xA2or\xA7filters\x91\x83\xA3col\xADshare_capital\xA3ope\xB3greater_or_equal_ | |
# th\xDD\x98[)\x8DL\f\v\x8C\f" | |
# MessagePack.unpack x | |
x2 = "\x82\xA9condition\xA2OR\xA6groups\x92\x82\xA9condition\xA2or\xA7filters\x91\x83\xA3col\xAAbirth_date\xA3ope\xA5month\xA3val\xA12\x82\xA9condition\xA2or\xA7filters\x91\x83\xA3col\xADshare_capital\xA3ope\xB3greater_or_equal_th\xDD\x98[)\x8DL\f\v\x8C\f" | |
MessagePack.unpack x2 |
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
MBA:~ tagomoris$ ruby msgpack_180_1.rb | |
msgpack_180_1.rb:3: invalid hex escape | |
...\x91\x83\xA3col\xAAbirth_date\x | |
MBA:~ tagomoris$ ruby msgpack_180_1.rb | |
Traceback (most recent call last): | |
2: from msgpack_180_1.rb:11:in `<main>' | |
1: from /Users/tagomoris/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/msgpack-1.3.3/lib/msgpack.rb:37:in `load' | |
/Users/tagomoris/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/msgpack-1.3.3/lib/msgpack.rb:37:in `full_unpack': end of buffer reached (EOFError) |
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
require 'msgpack' | |
require 'base64' | |
# b = "gqljb25kaXRpb26iT1KmZ3JvdXBzkoKpY29uZGl0aW9uom9yp2ZpbHRlcnORg6Njb2yqYmlydGhfZGF0ZaNvcGWlbW9udGijdmFsoTKCqWNvbmRp | |
# dGlvbqJvcqdmaWx0ZXJzkYOjY29srXNoYXJlX2NhcGl0YWyjb3BlsGdyZWF0ZXJvcmVxdWFsdG-jdmFspjUwMC4wMA" | |
# MessagePack.unpack Base64.decode64(b) | |
b = "gqljb25kaXRpb26iT1KmZ3JvdXBzkoKpY29uZGl0aW9uom9yp2ZpbHRlcnORg6Njb2yqYmlydGhfZGF0ZaNvcGWlbW9udGijdmFsoTKCqWNvbmRpdGlvbqJvcqdmaWx0ZXJzkYOjY29srXNoYXJlX2NhcGl0YWyjb3BlsGdyZWF0ZXJvcmVxdWFsdG-jdmFspjUwMC4wMA" | |
MessagePack.unpack Base64.decode64(b) |
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
MBA:~ tagomoris$ ruby msgpack_180_2.rb | |
Traceback (most recent call last): | |
2: from msgpack_180_2.rb:7:in `<main>' | |
1: from /Users/tagomoris/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/msgpack-1.3.3/lib/msgpack.rb:37:in `load' | |
/Users/tagomoris/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/msgpack-1.3.3/lib/msgpack.rb:37:in `full_unpack': end of buffer reached (EOFError) | |
MBA:~ tagomoris$ ruby msgpack_180_2.rb | |
Traceback (most recent call last): | |
2: from msgpack_180_2.rb:11:in `<main>' | |
1: from /Users/tagomoris/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/msgpack-1.3.3/lib/msgpack.rb:37:in `load' | |
/Users/tagomoris/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/msgpack-1.3.3/lib/msgpack.rb:37:in `full_unpack': end of buffer reached (EOFError) |
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
require 'msgpack' | |
require 'json' | |
json1 = <<EOJ | |
{"condition":"OR","groups":[{"condition":"or","filters":[{"col":"birth_date","ope":"month","val":"2"}]},{"condition":"or","filters":[{"col":"share_capital","ope":"greaterorequalto","val":"500.00"}]}]} | |
EOJ | |
MessagePack.unpack(MessagePack.pack(JSON.load(json1))) | |
json2 = <<EOJ | |
{"condition":"OR","groups":[{"condition":"or","filters":[{"col":"birthdate","ope":"month","val":"2"}]},{"condition":"or","filters":[{"col":"share_capital","ope":"greaterorequalto","val":"500.00"}]}]} | |
EOJ | |
MessagePack.unpack(MessagePack.pack(JSON.load(json2))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment