I'm trying to work on a serializer for objects coming from a Web Service call.

I've got a clean way of doing it for basic classes, but when the class has another custom class in it, I'm failing to figure it out.
Any help would be greatly appreciated.

  The highlighted code is what I'm having issues with.  If fullyQualifiedName="TestVO", then how do I use that String value as a Class so that I can call the objectToInstance function again?

Here's what I have so far...

package{
import mx.collections.ArrayCollection ;
import mx.utils.ObjectUtil;
import flash.utils.describeType;

public final class ObjectTranslator{
private static var _simpleTypes:ArrayCollection = new ArrayCollection(new Array(
"int",
"String",
"Object"
))

public static function objectToInstance(obj:Object, cls:Class):*{
var newObj:* = new cls();
var objClassInfo:Object = ObjectUtil.getClassInfo(obj);
var typeInfo:XML = describeType( cls );
for each (var prop:QName in objClassInfo.properties){
if (newObj.hasOwnProperty(prop.localName)){
var fullyQualifiedName:String = typeInfo..accessor.(@name == prop.localName)[EMAIL PROTECTED]().replace( /::/, "." );
var idx:int = _simpleTypes.getItemIndex(fullyQualifiedName);
if (idx == -1){
newObj[prop.localName] = ObjectTranslator.objectToInstance(obj[prop.localName], fullyQualifiedName as Class);
//translateObject(
//registerClassAlias( fullyQualifiedName, obj[ prop.localName] );
} else {
//var fullyQualifiedName:String = [EMAIL PROTECTED](prop.localName)[EMAIL PROTECTED]().replace( /::/, "." );
newObj[prop.localName] = obj[prop.localName ];
trace(prop.localName + ": " + ObjectUtil.isSimple(obj[prop.localName]));
}
}
}

return newObj;
}
}
}
__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Software development tool Software development Software development services
Home design software Software development company

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___

Reply via email to