jonnyreeves / as3-vanilla

Extract strongly typed Objects from dynamic objects without writing a single line of code!
http://www.jonnyreeves.co.uk/2011/08/getting-started-with-vanilla/
MIT License
81 stars 15 forks source link

Date object #9

Open pixelshaded opened 10 years ago

pixelshaded commented 10 years ago
Error: Could not coerce `UpdateDate` (value: 0001-01-01T00:00:00 <[class String]]>) from source object to [class Date] on target object
    at org.osflash.vanilla::Vanilla/extractValue()[/Users/jonny/Projects/as3/as3-vanilla/src/org/osflash/vanilla/Vanilla.as:110]
    at org.osflash.vanilla::Vanilla/injectFields()[/Users/jonny/Projects/as3/as3-vanilla/src/org/osflash/vanilla/Vanilla.as:65]
    at org.osflash.vanilla::Vanilla/extract()[/Users/jonny/Projects/as3/as3-vanilla/src/org/osflash/vanilla/Vanilla.as:46]

Getting a date object from c#, serialized to json, deserialized to javascript, passed to AS3 through external interface as an Object. Can this library convert date time strings to Date objects?

mayakwd commented 10 years ago

It would be better if you set [Transient]-tag for your field with the date and manually parse this string (because it is not a standard form for as3), something like:

[Transient]
public var date: Date;

[Marshall (field = "date")]
public function setDate (date: String): void {
   this.date = parseDate (date);
}