Skip to content

Commit a42deb5

Browse files
committed
Merge pull request android-async-http#526 from ldiqual/master
Use indexes for array parameters
2 parents 6077c6a + 0834d17 commit a42deb5

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

library/src/main/java/com/loopj/android/http/RequestParams.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -512,13 +512,15 @@ private List<BasicNameValuePair> getParamsList(String key, Object value) {
512512
}
513513
} else if (value instanceof List) {
514514
List list = (List) value;
515-
for (Object nestedValue : list) {
516-
params.addAll(getParamsList(String.format("%s[]", key), nestedValue));
515+
int listSize = list.size();
516+
for (int nestedValueIndex = 0; nestedValueIndex < listSize; nestedValueIndex++) {
517+
params.addAll(getParamsList(String.format("%s[%d]", key, nestedValueIndex), list.get(nestedValueIndex)));
517518
}
518519
} else if (value instanceof Object[]) {
519520
Object[] array = (Object[]) value;
520-
for (Object nestedValue : array) {
521-
params.addAll(getParamsList(String.format("%s[]", key), nestedValue));
521+
int arrayLength = array.length;
522+
for (int nestedValueIndex = 0; nestedValueIndex < arrayLength; nestedValueIndex++) {
523+
params.addAll(getParamsList(String.format("%s[%d]", key, nestedValueIndex), array[nestedValueIndex]));
522524
}
523525
} else if (value instanceof Set) {
524526
Set set = (Set) value;

0 commit comments

Comments
 (0)