1 Reply Latest reply on Feb 18, 2010 2:51 PM by Flex harUI

    How to convert a string to ByteArray?


      I have a textfile that store data.  If I read the data as a string s = 'all of the characters read from the text file' (i.e. = '{....}, {...}, ..., {...}' (see attached)


      Then I used the code below,


      var data:ByteArray = new ByteArray();



      var dobj:Object = JSON.decode(data.readUTFBytes(data.bytesAvailable));  // got error here


      I got error in the last line.  The error message is:

      JSONParseError: Unexpected end of input
      at com.esri.serialization.json::JSONTokenizer/parseError()[C:\checkout\flex_api\api\src\com\ esri\serialization\json\JSONTokenizer.as:569]
      at com.esri.serialization.json::JSONDecoder/parseValue()[C:\checkout\flex_api\api\src\com\es ri\serialization\json\JSONDecoder.as:209]
      at com.esri.serialization.json::JSONDecoder()[C:\checkout\flex_api\api\src\com\esri\serializ ation\json\JSONDecoder.as:73]
      at com.esri.serialization.json::JSON$/decode()[C:\checkout\flex_api\api\src\com\esri\seriali zation\json\JSON.as:88]



      How to debug this?  Thanks.