You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by Jack30t <bu...@gmail.com> on 2017/10/03 01:34:34 UTC

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

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/

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

Posted by Christofer Dutz <ch...@c-ware.de>.
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@c-ware.de%3E

Chris



Am 03.10.17, 03:37 schrieb "Jack30t" <bu...@gmail.com>:

    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/