I'm getting mad because of this. I'm using Parse.com to handle my Backend and I've to call a Cloud Code function giving this "structure":
{ "idShop":"asdf", "idCostumer":"zxcv", "selection": [
{"idOffer":"product1", "quantity":3 },
{"idOffer":"product2", "quantity":1 }
] }
It works fine if I use curl but, I've no idea how to do it with Android. So, the idea is put an array into a JSON value.
I've tried to put all the info into a String and into a HashMap array and I got no result.
Any idea??
Thanks for helping! :)
After Sunil answer:
This is what I'm doing and doesn't work:
HashMap<String, String [] > params = new HashMap<String, String []>();
params.put("idCostumer", new String[]{costumerId});
params.put("idShop", new String[]{idShop});
OfferListItem item;
ArrayList<String> selectionList = new ArrayList<String>();
for(int i=0; i<offerList.size();i++){
item = offerList.get(i);
if (item.getClicks()>0){
selectionList.add("\"idOffer\":"+item.getId()+", "+"\"quantity\":"+item.getClicks());
}
}
String [] selection = new String [selectionList.size()];
for (int i=0;i<selection.length;i++) {
selection[i]=selectionList.get(i);
}
params.put("selection", selection);