Reputation: 4562
I am trying to pass an array collection from flex page to my backend java.Here is the code,
private function getItems():void{
myObj = new Object();
myObj['dId']= dId.value.toString();
myObj['itmList']=JSON.encode(itmList);// trying to pass like this..
var url:String = URLManager.baseURL;
url = url+"myController/ReportController?do=getItems";
url = url+"¶meter="+ escape(JSON.encode(myObj))
var urlRequest:URLRequest = new URLRequest(url);
navigateToURL(urlRequest,"_blank");
}
My itmList
is an array collection, how can I pass it from JSon to Java controller? And how to get that in Java?
Upvotes: 1
Views: 292
Reputation: 3914
Another option is to use JSON.stringify instead (Flash has had native JSON support since FP 11). Just make sure you remove the import com.adobe.serialization.json.JSON;
from the top of your file.
myObj['itmList']=JSON.stringify(itmList);
Or, since you're encoding your whole data object,
myObj['itmList']=itmList.source;
var url:String = URLManager.baseURL;
url = url+"myController/ReportController?do=getItems";
url = url+"¶meter="+ escape(JSON.stringify(myObj))
var urlRequest:URLRequest = new URLRequest(url);
navigateToURL(urlRequest,"_blank");
Upvotes: 1
Reputation: 4877
JSON.encode the itmList source array instead. (i.e. itmList.source
is an array)
Then use HTTPService instead: HTTPService AsyncToken and AsyncResponder example
Upvotes: 3