Flex中Json的使用

在html中我们使用Json非常方便,可以用javascript的eval方法或者jQuery的方法:jQuery.parseJSON(jsonStr);
在Flex中,actionscript使用Json,将字符串转换为对象,可以使用如下方法:

1、调用外部javascript接口:

var jsonArr:Array=ExternalInterface.call("eval",jsonStr);

2、使用Adobe的JSON静态支持类:导入jsonLib的7个as类(或swc包)后使用如下语句

var jsonObj:* = JSON.decode(jsonStr);

 

第一种方法调用了javascript的eval方法,eval方法比较危险,使用时注意。

posted @ 2013-03-22 10:28  大树的博客  Views(224)  Comments(0Edit  收藏  举报