我正在更新 JSONArray 内的 JSONObject 中的值,当更改值时,会更新所有 JSONArray 中的值。有人知道为什么吗?
public static void uploadMediaWithThumbnail( final LeagueActivity.UploadingCallback call,
final long leagueId,
final JSONArray information, final JsonHttpResponseHandler handler) {
final AtomicInteger receivedCount = new AtomicInteger();
receivedCount.set(0);
call.progressCall(10);
getMediaUploadUrl(leagueId, information, new JsonHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
try {
call.progressCall(20);
final JSONArray allData = response.getJSONArray("upload_data");
AsyncHttpClient[] clients = new AsyncHttpClient[allData.length()*2];
JSONArray jarr = information;
for (int i = 0; i < allData.length(); i++ ) {
final String uploadUrl = allData.getJSONObject(i).getString("content_url");
final String previewUrl = allData.getJSONObject(i).getString("preview_url");
jarr.getJSONObject(i).put("content", uploadUrl);
jarr.getJSONObject(i).put("preview", previewUrl);
}
final JSONArray newInfo = shallowCopy(jarr);
Log.d("Log1", newInfo.getJSONObject(1).getString("content"));
Log.d("Log2", newInfo.getJSONObject(0).getString("content"));
记录 Log1 和 Log2 时,它们包含相同的链接
信息是这样的数据[{"type":"video","format":"mp4","preview_format":"jpg"}, {"type":"video","format":"mp4","preview_format":"jpg"}]
AllData 是从 REST HTTP 调用接收到的信息,并且与信息具有相同的长度
慕无忌1623718
12345678_0001
相关分类