Serialize java.util.HashMap as ASObject, java.util.ArrayList as Array

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Serialize java.util.HashMap as ASObject, java.util.ArrayList as Array

Jack30t
This post was updated on .
Hey,
I just switched from Adobe Flex BlazeDS to Apache Flex BlazeDS.
BlazeDS 4.0.0 serialized java.util.HashMap as Object and java.util.ArrayList
as Array while BlazeDS 4.7.3 serializes both as "Mixed Array". Is it somehow
possible to recieve first one's serialization with BlazeDS 4.7.3?



--
Sent from: http://apache-flex-development.2333347.n4.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: Serialize java.util.HashMap as Object, java.util.ArrayList as Array

Christofer Dutz
Hi Niklas,

Use the SerializationContext class to fine-tune the serialization.
Here an example I use in my projects.

    @PostConstruct
    public void configureSerializationContext() {
        //ThreadLocal SerializationContent
        SerializationContext serializationContext = SerializationContext.getSerializationContext();
        serializationContext.enableSmallMessages = true;
        serializationContext.instantiateTypes = true;
        //use _remoteClass field
        serializationContext.supportRemoteClass = true;
        //false  Legacy Flex 1.5 behavior was to return a java.util.Collection for Array
        //true New Flex 2+ behavior is to return Object[] for AS3 Array
        serializationContext.legacyCollection = false;

        serializationContext.legacyMap = false;
        //false Legacy flash.xml.XMLDocument Type
        //true New E4X XML Type
        serializationContext.legacyXMLDocument = false;

        //determines whether the constructed Document is name-space aware
        serializationContext.legacyXMLNamespaces = false;
        serializationContext.legacyThrowable = false;
        serializationContext.legacyBigNumbers = false;

        serializationContext.restoreReferences = false;
        serializationContext.logPropertyErrors = false;
        serializationContext.ignorePropertyErrors = true;
    }

And please note that in the latest 4.7.3 version we intentionally turned off deserialization of XML content and deserialization of objects that are not whitelisted.

See here for more details:
https://mail-archives.apache.org/mod_mbox/www-announce/201703.mbox/%3C5B016865-2001-479A-9D81-AD8267D78255@...%3E

Chris



Am 03.10.17, 03:37 schrieb "Jack30t" <[hidden email]>:

    Hey,
    I just switched from Adobe Flex BlazeDS to Apache Flex BlazeDS.
    BlazeDS 4.0.0 serialized java.util.HashMap as Object and java.util.ArrayList
    as Array while BlazeDS 4.7.3 serializes both as "Mixed Array". Is it somehow
    possible to recieve first one's serialization with BlazeDS 4.7.3?
   
   
   
    --
    Sent from: http://apache-flex-development.2333347.n4.nabble.com/