我希望能创建一个像这样的
这是我的代码:
JSONObject
:[
{
id:01,
name:"John",
number:010
},
{
id:02,
name:"Mike",
number: 020
}
]
这是我的代码:
public void equipmentViewed(List<Equipment> equipmentSelected, final OnControlResponseListener listener, String description, Equipment equipment) throws JSONException {
wsAccessControl = WSAccessControl.getInstance();
EquipmentViewed equipmentViewed = new EquipmentViewed();
equipmentViewed.setEquipment(equipmentsCount(equipmentSelected));
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("", new JSONArray(equipmentViewed.getEquipment().toString()));
} catch (JSONException e) {
Log.e(TAG, "Failed to create json object. Cause: " + e.getMessage());
}
String url = Constants.PROVIDER_DOMAIN_URL + Constants.REQUEST_EQUIPMENT;
wsAccessControl.makeWSRequest(RequestType.POST, url, jsonObject, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
listener.OnResponseReceived(response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
listener.OnResponseError(error);
}
}, true);
}
EquipmentViewed
包含一个 String
列表 equipment。
equipmentViewed.getEquipment()
返回的是什么字符串?请分享。 - ρяσѕρєя K