<?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>
Flex中使用Json
最新推荐文章于 2025-04-05 23:31:32 发布