Cleaning out my list mail and came across this ... I have a sample of this,
I put together awhile back, if anyone's interested. It's a JSON
implementation, but it piggy-backs on all the same principles here.

http://booleanbetrayal.com/2007/05/18/httpservice-xmldecode-objecttranslator-and-rabidsquirrels/



On Thu, Dec 4, 2008 at 10:34 PM, bpjadam <[email protected]> wrote:

>
> So as a followup to my own thread, I've written a drop-in replacement for
> SimpleXMLDecoder / Encoder that I call TypedXMLDecoder/Encoder..
>
> Rather than turning an XML doc into a tree of plain-jane Object (or
> ObjectProxy) instances, it directly creates a graph of typed instances
> using
> a simple XML element -> AS type mapping table you provide. Thus, each chunk
> of XML is only examined once and unmarshalled directly into an AS3 typed
> instance object.
>
> It's also smart enough to use the reflective machinery in AS3
> (specifically,
> DescribeTypeCache and friends) to figure out what AS type you *really* want
> for nested objects based on their declared type in your AS class
> definitions, thereby saving you the trouble of putting all possible types
> into the mapping table. You only need to specify the possible "root"
> element
> to type mappings and you do *not* have to put helper methods in your AS
> classes to deal with the marshalling/unmarshalling.
>
> I've got it handling Array and ArrayCollection properly as well as
> respecting the [Transient] metadata tag when encoding as XML.
>
> XML attributes can either be handled as properties (the default) or can be
> handled specially as "meta" and stashed in a distinct attributes dict
> handing off the instances. This latter option allows for symmetry with
> encoding the objects back into XML.
>
> And finally, if no type map entry can be figured out, it falls back to
> creating regular Object (or ObjectProxy) instances.
>
> So far, it's working well in our project against a nice REST service
> interface we've built for our application. If there's enough interest out
> there and I can get clearance from my employer, I'll open source the thing.
> --
> View this message in context:
> http://www.nabble.com/Creating-strongly-typed-objects-from-HTTPService-results-tp16182400p20847252.html
> Sent from the FlexCoders mailing list archive at Nabble.com.
>
>  
>

Reply via email to