JSONObject can accept Java objects, try using
Map<String,Object>
something like that:
String mUrl;
ArrayList<String> mUrlDove;
Map<String, Object> jsonParams = new HashMap<>();
jsonParams.put("url", mUrl);
jsonParams.put("urlDove", mUrlDove);
JsonObjectRequest request = new JsonObjectRequest(Request.Method.POST, url, new JSONObject(jsonParams),
new Response.Listener<JSONObject>()
{
@Override
public void onResponse(JSONObject response)
{
Log.d("Volley Response: ", response.toString());
}
},
new Response.ErrorListener()
{
@Override
public void onErrorResponse(VolleyError error)
{
if (null != error.networkResponse)
{
Log.d(" Volley Error Code: ", "" + error.networkResponse.statusCode);
}
}
});
requestQueue.add(request);
this works for me with complex objects like
Map<String,<List<Map<String,Object>>>
most internal objects are strings and integers, and List is initialized as a new ArrayList.
Hope this helps!
source
share