Думал, что выложу более чистый пример.
-------- JsonHttpService.as
package services
{
import mx.rpc.http.HTTPService;
import mx.rpc.http.SerializationFilter;
public class JsonHttpService extends HTTPService
{
private var jsonFilter:JsonSerializationFilter = new JsonSerializationFilter();
public function JsonHttpService(rootURL:String=null, destination:String=null)
{
super(rootURL, destination);
resultFormat = "json";
}
override public function get serializationFilter():SerializationFilter {
return jsonFilter;
}
}
}
--- JsonSerializationFilter.as
package services
{
import mx.rpc.http.AbstractOperation;
import mx.rpc.http.SerializationFilter;
public class JsonSerializationFilter extends SerializationFilter
{
public function JsonSerializationFilter() {
SerializationFilter.registerFilterForResultFormat("json", this);
super();
}
override public function deserializeResult(operation:AbstractOperation, result:Object):Object {
return JSON.parse(result as String);
}
override public function getRequestContentType(operation:AbstractOperation, obj:Object, contentType:String):String {
return "application/json";
}
override public function serializeBody(operation:AbstractOperation, obj:Object):Object {
return JSON.stringify(obj);
}
}
}