0 Replies Latest reply on Mar 17, 2010 3:16 PM by JosephFley

    Casting object after JSON decoding




      Im currently lerning about Flex and how to exchange data with PHP. I'm using JSON to send data from the server, and using corelib to decode it, then I wish to do something like this:



      user  = JSON.decode(rawData) as User;



      Because I have binds to the "user" properties and want them to be updated with the data from the decoder, but the casting fails leaving a null object, even tho Im sure the properties of both objects are the same.


      In the end I have to do something like this:


      var temp:Object = (JSON.decode(rawData));
      user.id = temp.id;
      user.name = temp.name;

      user.email = temp.email;



      So is there an "automatic" or better way of doing this?


      Thanks a lot.


      PD: Sorry for my bad english.