私はこのようなJSONを送信する必要があります:文字列だけではなく、配列を送信私はどのようにボレーを介して文字列配列を送ることができますか?
{
"user_id": "5750891ffe77d2d41732d535",
"categories" :["5751cd8cb61c39200b368cf3","575b35b9c456c8751cd8530f", "575b35c5c456c8751cd85313"]
}
が、ボレー。これは私がボレーを使用しています、私のリクエストクラスであるStringRequestしかし、私はまた、配列を送信する方法があると思う:
public class VolleyRequest extends StringRequest {
private Map<String, String> params;
Context context;
public VolleyRequest(int method, final Context context, String url, Map<String, String> params, final Response.Listener<String> listener) {
super(method, url, listener, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
Log.d("WS", volleyError.toString());
}
});
setRetryPolicy(new DefaultRetryPolicy(10000, 10, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
this.params = params;
this.context = context;
}
@Override
public String getBodyContentType() {
return "application/x-www-form-urlencoded; charset=UTF-8";
}
@Override
public Map<String, String> getParams() throws AuthFailureError {
return this.params;
}
}
[JSONオブジェクトのためのバレーボールPostメソッド]の可能性のある重複します(http:/その文字列を使用Gsonと私の希望JSONボディのモデルを作成するには/stackoverflow.com/questions/25906689/volley-post-method-for-json-object) –