AStream is a XML to Object (and vice versa) mapping library. It was started as an attempt to implement an AS3 backend for Java XStream services. The library can handle primitive values, complex typed objects (with cycle- and corss-references), collections (arrays, vectors and all based on mx.collections.IList), implicit collections, classes based on IExternalizable and even enums (classes based on as3.lang.Enum in library).

The library is compatible with XStream.


import com.example.domain.User;
import com.example.domain.UserRole;

import flash.display.Sprite;

import ru.kokorin.astream.AStream;

public class Main extends Sprite {
    public function Main() {
        const aStream:AStream = new AStream();
        //or aStream.autodetectMetadata(true);

        const user:User = new User(); = 1; = "Ivanov Ivan";
        user.role = UserRole.ADMINISTRATOR;

        const xml:XML = aStream.toXML(user);
        /* xml.toXMLString()
                <name>Ivanov Ivan</name>

        const restoredUser:User = aStream.fromXML(xml) as User;
        /* restoredUser.toString()
        User{_name=Ivanov Ivan,id=1,role=ADMINISTRATOR} */
Serialization . URL.