You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My requirement is that map nested objects are converted into Java objects, and there are nested objects in objects. In this case, they cannot be copied successfully.
Null is displayed
@test
public void testMapToBean() {
Map<String, Object> map = new HashMap();
map.put("name", "abcdef");
Map<String, Object> subMap = new HashMap<>();
subMap.put("subName", "aaaaaaaa");
map.put("subUser11", subMap);
final DefaultMapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
mapperFactory.classMap(Map.class, UserA.class)
.field("name", "name")
.field("subUser11['subName']", "subUser.subName")
.byDefault()
.register();
UserA userA = new UserA();
mapperFactory.getMapperFacade(Map.class, UserA.class).map(map,userA );
System.out.println("sub::::"+userA.getSubUser().getSubName());
}
public static class UserA {
private String name;
private SubUser subUser;
public SubUser getSubUser() {
return subUser;
}
public void setSubUser(SubUser subUser) {
this.subUser = subUser;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
public static class SubUser {
public String subName;
public String getSubName() {
return subName;
}
public void setSubName(String subName) {
this.subName = subName;
}
}
The text was updated successfully, but these errors were encountered:
Thank you very much for your reply
My requirement is that map nested objects are converted into Java objects, and there are nested objects in objects. In this case, they cannot be copied successfully.
Null is displayed
@test
public void testMapToBean() {
Map<String, Object> map = new HashMap();
map.put("name", "abcdef");
public static class UserA {
private String name;
private SubUser subUser;
The text was updated successfully, but these errors were encountered: