我们可以使用Android volley将JsonObject或JsonArray发布到服务器吗?如果是的话,请发送工作示例。 如果我发布字符串,那么它工作正常,但我发布jsonObject或jsonArray时有一些问题。android volley for posting jsonobject
0
A
回答
0
是的,你可以。的JSON加入到POST请求的主体,这样的:
JSONObject jsonObject; // your JSON here
requestQueue.add(new JsonObjectRequest(Method.POST, url, jsonObject, listener, errorListener);
0
是,只需添加数据的JSONObject并传递该对象在请求中。
JSONObject jsonObject = new JSONObject();
jsonObject.put("name", name);
jsonObject.put("password", password);
RequestQueue queue = Volley.newRequestQueue(context);
JsonObjectRequest jsObjRequest = new JsonObjectRequest(Request.Method.POST, URL, jsonObject, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Log.i("volley", "response: " + response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.i("volley", "error: " + error);
}
});
相关问题
- 1. Android JSONObject使用StringRequest的Post Volley
- 2. 发布JsonObject与Volley
- 3. 的Android for的JSONObject
- 4. 使用Volley存储JsonObject
- 5. Android Volley with Viewpager for news feed
- 6. 将Volley的JSONObject响应转换为POJO
- 7. 如何解析另一个JSONObject内的JSONObject,使用Android Volley进行HTTP连接
- 8. Android Volley POST ServerError
- 9. Android Volley响应
- 10. CouchDB通过Android返回错误的JSONObject GET响应Volley
- 11. Android Volley POST JSONObject与int,字符串和jsonobjects
- 12. Android Volley - java.lang.OutOfMemoryError
- 13. Android Volley Double Post
- 14. Android AsyncTask Volley
- 15. 发布JSONObject并获取JSONArray请求Volley
- 16. Android Volley + JSONObjectRequest缓存
- 17. Volley android java.lang.NullPointerException
- 18. Android Volley Requestqueue
- 19. Android Volley error.getMessage()为空
- 20. Android JsonObject检索
- 21. Android Volley请求不响应
- 22. Android Volley,JsonObjectRequest但接收JsonArray
- 23. Android Volley POST不起作用
- 24. Android Volley响应循环
- 25. Android中的JsonRequest VS StringRequest Volley
- 26. 的Android -Volley通用请求
- 27. Volley Android:空指针异常
- 28. Android Volley onResponse获取数据
- 29. 在Volley中传递POST请求中的原始JSONObject
- 30. Android JSONObject转换
以及如何通过php在服务器上检索它? –
我不知道太多的PHP,但你肯定可以得到http请求的正文。 –