我必须在Volley Post请求的参数函数中向服务器发送2个对象,但是我不知道如何向服务器发送数据?
我尝试搜索,但未找到结果。
这是我发送到服务器的对象
{
"customer_email": "jawadsaqib6@gmail.com",
"customer_phone": "03342234332",
"shipping": {
"first_name": "saham",
"last_name": "nadeem",
"address_1": "asdadjjslajslldjslds",
"address_2": "",
"city": "Islamabad",
"zip": "44000",
"country": "US",
"state": "AL"
},
"products": [
{
"product_id": 25,
"qty": 2,
"options": [
{
"16": 61
}
]
}
]
}
我做对象并尝试发送数据
Cart_CheckOut.Billing billing;
private void checkOut_Order() {
StringRequest stringRequest = new StringRequest (Request.Method.POST, CHECKOUT_URL, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try{
JSONObject jsonObject= new JSONObject(String.valueOf(response));
String msg = jsonObject.getString("message");
}
catch (JSONException e){
Toast.makeText(ShippingInfo.this, "Exception", Toast.LENGTH_SHORT).show();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
})
{
@Override
protected Map<String, String> getParams() {
Map<String, String> hashMap = new HashMap<>();
hashMap.put("customer_email", "");
hashMap.put("customer_phone", "");
hashMap.put("billing",billing);
return hashMap;
}
};
RequestQueue requestQueue = Volley.newRequestQueue(this);
requestQueue.add(stringRequest);
}
我不知道如何将对象发送到服务器。