0 Replies Latest reply on Sep 10, 2008 4:36 PM by Ladislav2

    Byte array in JSON reply

    Ladislav2
      Hi guys,

      I'm exchanging some data between .net webservice and flex with JSON. This is a JSON reply:

      <string>
      {"uid":"23","photos":[[255,216,255,224,0,16,74,70,73,70,0,1,1,1,0,72,0,72,0,0,255,219,0,67 ,0,8,6,6,7,6,5,8,7,7,7,9,9,8,10,12,20
      .....
      ]]}
      </string>

      It is serialized this class:

      public class UserPhotoBytes
      {
      public string uid;
      public ArrayList photos;

      public UserPhotoBytes()
      {

      }
      }

      Where photos is THE ARRAY OF BYTE ARRAYS. Then in Flex I deserialize it with:

      public function onPhotoReceived(event:GetUserPhotoResultEvent):void
      {
      var myImg:Image = new Image();
      var rawData:String = String(event.result);
      var userPhoto:Object = JSON.decode(rawData) as Object
      _user.photos = userPhoto.photos as Array;
      myImg.data = _user.photos[0] as ByteArray;

      But I think it cannot convert the string value of byte array of JSON object to real byte representation. Or am I missing something else ? Thank you very much for the response