这是我从一位网友里看的例子,发现用Json真的很方便。附件中是Json类包
参考网址:http://flash.9ria.com/thread-1657-1-1.html
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()"> <mx:Script> <![CDATA[ import com.adobe.serialization.json.*; private var jsonStr:String; private var jsonObj:Object; private var jsonObj2:Object; private var jsonStr2:String; internal function init():void{ jsonStr = '{"name":"zhanzhihu","age":22,"gender":"male"}'; jsonObj = new Object(); jsonObj = JSON.decode(jsonStr); trace(jsonObj.name); jsonObj2 = new Object(); jsonObj2.firstName = "bill"; jsonObj2.lastName = "Gate"; jsonObj2.com = "Microsoft"; jsonStr2 = JSON.encode( jsonObj2 ); trace( jsonStr2 ); } ]]> </mx:Script> </mx:Application>