I'm using as3corelib to decode/encode JSON strings. In my little experiment I want to encode
an object (UserInfo
) to JSON string and decode it back to the object, however it seems to fail at the convertion point (the last line), why would that happen? how can I make it work?
The UserInfo
class
public class UserInfo
{
public var levelProgress : int;
}
The conversion code
var user1:UserInfo = new UserInfo()
user1.levelProgress = 20;
var a:String = JSON.encode(user1);
var b:Object = JSON.decode(a);
var c:UserInfo;
c = b as UserInfo; // c gets null, why?