80,351
社区成员
发帖
与我相关
我的任务
分享
try {
JSONArray jsonArray = new JSONArray();
for (UserAddress u : userAddresses) {
JSONObject jsonObj = new JSONObject();
jsonObj.put("address", u.getAddress());
jsonObj.put("telephone", u.getTelephone());
jsonArray.put(jsonObj);
}
Log.d("ModelToJson", "jsonArray:" + jsonArray.toString());
}catch (Exception ex){
ex.printStackTrace();
}
try {
JSONArray array = new JSONArray();
for ( Address address: addresses){
JSONObject jsonObject = new JSONObject();
jsonObject.put("addr", address.getAddr());
array.put(jsonObject);
}
System.out.println(array);
} catch (JSONException e) {
e.printStackTrace();
}