Chahat Balhara Chahat Balhara - 1 year ago 70
Android Question

Send ArrayList<Hashmap<String,Object>> to webservice using json

i want to send data to server in the

. I am trying to send it using
. I am able to store the data in it, but don't know how to send it to service or web service. Please help, I have searched all but didn't get the appropriate solution. Thanks in advance!

Answer Source

create a class like

class MyData {
ArrayList<Hashmap<String,Object>> dataList;

create a object of this class

MyData obj = new MyData();

and store the data in dataList using this object

obj.datalist = (data which you want to save in this array)

Now, create a object of Gson class

Gson gson = new Gson();
String json = gson.toJson(obj);

and pass this json object to your server using POST request. Hope it will help you.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download