`
xxwinnie
  • 浏览: 110074 次
  • 性别: Icon_minigender_1
  • 来自: 佛山
社区版块
存档分类
最新评论

在Flex中使用JSON

    博客分类:
  • Flex
阅读更多
要把一个字符串传到Flex前台~ 已经写好,结果又需要传多一个,不想改太多~
正好闲来无事,就想用用Json~

其实也很简单,就改一点点~(仅示改动地方)
...
import com.adobe.serialization.json.JSON;
...

private function someHandle():void {
  //get the raw JSON data and cast to String  
  var rawData:String = String(event.result);  
  
  //decode the data to ActionScript using the JSON API  
  //in this case, the JSON data is a serialize Array of Objects.  
  var arr:Array = (JSON.decode(rawData) as Array);  
  
  //create a new ArrayCollection passing the de-serialized Array  
  //ArrayCollections work better as DataProviders, as they can  
  //be watched for changes.  
  var dp:ArrayCollection = new ArrayCollection(arr);  
  
  //pass the ArrayCollection to the DataGrid as its dataProvider.  
  grid.dataProvider = dp;  
}

一般情况下会没有包含com.adobe.serialization这个包的包,我给附上了~

就这么简单,然后在后台里修改相应返回值为Json格式就行了~
分享到:
评论
1 楼 lliiqiang 2013-07-17  
网站输入法有很多地方无法切换,只需到浏览器其它位置点一下,再点回来就可以输入了.

相关推荐

Global site tag (gtag.js) - Google Analytics