title: Parsing JSON in ActionScript (Adobe Flex). JSON.decode(string) returns null
body: <p>I am trying to parse JSON file in my Flex project. I included as3corelib.swc and imported com.adobe.serialization.json.JSON, but JSON.decode() function still returns null. What might be the problem?</p>
  
  <pre><code>[Embed(source="assets/test.json",mimeType="application/octet-stream")]
  private var json_file:Class;
  
  public function load():void
  {
      var bytes:ByteArray = new json_file();
      var json:String = bytes.readUTFBytes(bytes.length);
      trace(json); // String is OK!
      var arr:Array = (JSON.decode(json) as Array);
      trace(arr); // Array is null!
  }
  </code></pre>
  
  <p>I also tried:</p>
  
  <pre><code>    var str:String = (JSON.decode(json) as String);
      trace(arr); // null!
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>    var arr:Object = JSON.decode(json); // [object Object]
      trace(arr.toString()); // empty string
  </code></pre>
  
  <p>Thanks for your time.</p>