Skip to content

Commit

Permalink
Version 0.4.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Arraying authored and Arraying committed Jul 5, 2018
1 parent 421fa72 commit 752e095
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/main/java/de/arraying/kotys/JSONORM.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,25 @@ T mapTo(JSON json, String... ignoredJSONKeys)
if(!json.has(key)) {
continue;
}
Class<?> type = field.getType();
Object rawValue = json.object(key);
Object value;
if(rawValue instanceof JSON) {
value = ((JSON) rawValue).marshal(field.getType());
if(type.equals(JSON.class)) {
value = rawValue;
} else {
value = ((JSON) rawValue).marshal(type);
}
} else if(rawValue instanceof JSONArray) {
Class<?> fieldType = field.getType().getComponentType();
if(fieldType.isPrimitive()) {
throw new IllegalArgumentException("Array type " + fieldType + " is primitive");
if(type.equals(JSONArray.class)) {
value = rawValue;
} else {
Class<?> fieldType = type.getComponentType();
if(fieldType.isPrimitive()) {
throw new IllegalArgumentException("Array type " + fieldType + " is primitive");
}
value = ((JSONArray) rawValue).marshal(fieldType);
}
value = ((JSONArray) rawValue).marshal(fieldType);
} else {
value = rawValue;
}
Expand Down

0 comments on commit 752e095

Please sign in to comment.