Skip to content
This repository was archived by the owner on Dec 31, 2024. It is now read-only.

fix missing form field subObject problem #119

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion feign-form/src/main/java/feign/form/util/PojoUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,20 @@ public static Map<String, Object> toMap (@NonNull Object object) {
? field.getAnnotation(FormProperty.class).value()
: field.getName();

result.put(propertyKey, fieldValue);
//fix missing form field subObject problem
if (fieldValue instanceof Collection) {
int i = 0;
for (Object o : ((Collection) fieldValue)) {
Map<String, Object> map = toMap(o);
for (Map.Entry<String, Object> entry : map.entrySet()) {
result.put(propertyKey + "[" + i + "]." + entry.getKey(), entry.getValue());
}
i++;
}
} else {
result.put(propertyKey, fieldValue);
}

}
return result;
}
Expand Down