json - Android Volley JsonArrayRequest send and get List<Object> -
i want send jsonarrayrequest linkedlist param , same type result. error 400 means wrong request:
requestqueue volleyqueue = volley.newrequestqueue(context); final type type = new typetoken<linkedlist<myclass>>() {}.gettype(); linkedlist<myclass> data = new linkedlist<>(); //populate data... try { jsonarrayrequest request = new jsonarrayrequest( request.method.get, base_url, new jsonarray(new gson().tojson(data)), new response.listener<jsonarray>() { @override public void onresponse(jsonarray response) { try { processresultdata((linkedlist<myclass>) new gson().fromjson(response.tostring(), type)); } catch (exception e) {} } }, new response.errorlistener() { @override public void onerrorresponse(volleyerror error) { } } ); request.setretrypolicy(new defaultretrypolicy(volley_time_out, defaultretrypolicy.default_max_retries, defaultretrypolicy.default_backoff_mult)); volleyqueue.add(request); } catch (exception e) {}
on server side it's java spring boot application means:
@restcontroller public class apiclass { @requestmapping("/base_url") public linkedlist<myclass> foo(@requestbody linkedlist<myclass> data) { ... } }
Comments
Post a Comment