Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serializer discards a class name in TypedHash #11

Open
Teshootub7 opened this issue Mar 8, 2012 · 1 comment
Open

Serializer discards a class name in TypedHash #11

Teshootub7 opened this issue Mar 8, 2012 · 1 comment

Comments

@Teshootub7
Copy link

Hi,

When I deserialize AMF3 data, modify it, and then serialize it, I noticed class names in AMF3 Objects is discarded.
For example:

require 'rocketamf'⏎
amf3_object_with_classname = "\x0a\x0b\x13ClassName\x01\x01"⏎
data = RocketAMF.deserialize( amf3_object_with_classname, 3 )⏎
p data.type # => "ClassName"⏎
data = RocketAMF.deserialize( RocketAMF.serialize( data, 3 ), 3 )⏎
p data.type # => ""⏎

I expect the class name "ClassName" is kept on serialization, but RocketAMF.serialize discards the class name and it will be an empty string instead. I know it can be avoided by mapping the class names, but it would be very convenient if class names in AMF3 Object is kept out-of-the-box. Especially, a class name stored in TypedHash should be kept because TypedHash is used to store the AMF3 Object and its class name.

I hope the following spec to be passed.

diff --git a/spec/class_mapping_spec.rb b/spec/class_mapping_spec.rb
index 16ff524..1a674b7 100644
--- a/spec/class_mapping_spec.rb
+++ b/spec/class_mapping_spec.rb
@@ -25,6 +25,10 @@ describe RocketAMF::ClassMapping do
       @mapper.get_as_class_name('BadClass').should be_nil
     end

+    it "should return the same AS class as of TypedHash" do
+      @mapper.get_as_class_name(RocketAMF::Values::TypedHash.new("UnmappedClass")).should == 'UnmappedClass'
+    end
+
     it "should instantiate a ruby class" do
       @mapper.get_ruby_obj('ASClass').should be_a(ClassMappingTest)
     end

Regards,

@wolfovich
Copy link

Could you explain how mapping the class names? I have array expect object :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants