Flex 前端的代碼
<s:HTTPService id="jsonService" url="jsonAction" resultFormat="text" result="jsonService_resultHandler(event)"/>
protected function jsonService_resultHandler(event:ResultEvent):void
{
var rawData:String = event.result as String;
//單引號替換爲雙引號
rawData = rawData.replace(/\'/g,"\"");
var result:Object = JSON.parse(rawData);
Alert.show(result.username);
Alert.show(result.password);
}
其中後臺返回的數據格式爲::”{'username':'simon1','password':'123'}“