ActionScript处理JSON格式的数据
2011-07-05 15:30
330 查看
1、需要在flex的SDK中加入as3corelib.swc(该文件250K,网上有下载,如果下载下来的没有250k,不能使用),以我本机为例,将该文件放到:D:\Adobe\Flex Builder 3 Plug-in\sdks\3.2.0\frameworks\libs文件夹下,重新打开编辑器。
2、使用时需要引入import com.adobe.serialization.json.*;
3、但是对JSON有严格的格式要求,即属性和值都要有双引号,否则解析不出来。
4、这里简单给出使用的例子:
2、使用时需要引入import com.adobe.serialization.json.*;
3、但是对JSON有严格的格式要求,即属性和值都要有双引号,否则解析不出来。
4、这里简单给出使用的例子:
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" height="534" width="1122"> <mx:Script> <![CDATA[ import com.adobe.serialization.json.JSON; import mx.collections.ArrayCollection; public var rawData:String = '[{"name":"stone","sex":"男","teleNum":"15903396795"},' + '{"name":"huangyunzeng","sex":"男","teleNum":"15903396795"},' + '{"name":"huangyz","sex":"男","teleNum":"15903396795"}]'; public var arr:Array = (JSON.decode(rawData) as Array); [Bindable] public var dp:ArrayCollection = new ArrayCollection(arr); ]]> </mx:Script> <mx:RemoteObject id="firstRO" destination="testHello"/> <mx:Panel width="702" height="280" layout="absolute" title="我的面板" x="236" y="86"> <mx:DataGrid x="161" y="27" height="156" dataProvider="{dp}"> <mx:columns> <mx:DataGridColumn headerText="姓名" dataField="name"/> <mx:DataGridColumn headerText="性别" dataField="sex"/> <mx:DataGridColumn headerText="电话号码" dataField="teleNum"/> </mx:columns> </mx:DataGrid> </mx:Panel> </mx:Application>
相关文章推荐
- 一个java处理JSON格式数据的通用类(封装了一个class)
- [javase][json]fastJson在java后台转换json格式数据探究--处理数组/List/Map
- JS 对java返回的json格式的数据处理方法
- 使用 C++ 处理 JSON 数据交换格式
- java处理JSON格式数据的常用技术(一)
- JS处理Json格式数据
- 使用 C++ 处理 JSON 数据交换格式
- 【转】使用 C++ 处理 JSON 数据交换格式
- 使用 C++ 处理 JSON 数据交换格式
- mybatis 处理数组类型及使用Json格式保存数据 JsonTypeHandler and ArrayTypeHandler
- 用Jquery处理PHP返回的JSON格式数据的三种方法
- jQuery备忘之(一):jQuery处理.Net后台返回的Xml格式与Json格式的数据的比较分析
- 关于http接口开发中json格式数据编码问题处理
- 使用 C++ 处理 JSON 数据交换格式
- EasyNet.Solr系列:处理xml或者json格式返回数据
- 调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据(转)
- 使用 C++ 处理 JSON 数据交换格式
- 使用 C++ 处理 JSON 数据交换格式
- Ajax处理XML、HTML、JSON三种数据格式的方法
- 使用jq工具处理json格式数据