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'}“