如何将 json 数组转换为 flex 4 数组(as3)?
朋友们...我的json数组是
{"result":[{"status":0,"statusmsg":"Sorry, that's an invalid domain\n","rawout":null,"options":null}]}
如何将这个json数组转换成flex 4数组(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 a flex 4 array (as3)?
Thanks for all help's
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要下载 as3corelib 库并将其添加到您的库路径
https://github.com/mikechambers/as3corelib
然后,您可以使用 JSON 解码方法,该方法将返回一个对象。
你应该能够将你的对象强制转换为数组,你可以尝试
但是如果由于某种原因这不起作用,
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.
but you should be able to coerce your Object into an Array
if for some reason, this doesn't work, you could try
我找到了一种在jsf页面中通过javascript、el发送json的方法,
首先,我使用java中的flexjson库对对象的数组列表进行编码。
2)这个对象我把它放在一个java bean中
3)我用oncomplete事件调用javascript
4)像这样 callapp(#{bean.jsonString})
5)这是通过外部接口在flex中接收的
ExternalInterface.addCallback
http://help.adobe.com/en_US/flex/ using/WS2db454920e96a9e51e63e3d11c0bf69084-7e92.html
6)然后发生了一些奇怪的事情,json字符串被转换为ACTIONSCRIPT的对象数组
所以我只需要循环遍历数组,并获取对象属性和 buala ...
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 …
这是使用flex 4.5内部库的更简单的方法(尚未使用flex 4进行测试)
Here is a simpler way using flex 4.5 internal library (haven't test with flex 4)