开发者

How to convert a json array into a flex 4 array (as3)?

friends... my json array is

{"result":[{"status":0,"statusmsg":"Sorry, that's an invalid domain\n","rawout":null,"options":null}]}

how to convert this a json array into 开发者_StackOverflow社区a flex 4 array (as3)?

Thanks for all help's


You will need to download the as3corelib library and add it to your Library path
https://github.com/mikechambers/as3corelib

You can then use the JSON decode method which will return an Object.

    var object:Object = JSON.decode( jsonString );

but you should be able to coerce your Object into an Array

    var array:Array = object as Array;

if for some reason, this doesn't work, you could try

    var array:Array = [];
    for( var prop:String in obj )
        array.push( obj[prop] );


i found a way to send json through javascript, el, in a jsf page, first i enconde the the arraylist of objects with the flexjson library in java.

2) the this object i put it in a java bean 3) the i call the javascript with the oncomplete event 4) like this callapp(#{bean.jsonString}) 5) this is received in flex with the external interface ExternalInterface.addCallback

http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7e92.html

6) then something weird occurs, the json string is converted in a array of objects of ACTIONSCRIPT so i just have to loop through the array, and obtain the objects properties and buala …


Here is a simpler way using flex 4.5 internal library (haven't test with flex 4)

import com.adobe.serializers.json.JSONDecoder;
var j:JSONDecoder= new JSONDecoder();   
var obj:Object= j.decode(json string);
myarray= obj as ArrayCollection;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜