Skip to content

Commit 752e095

Browse files
ArrayingArraying
authored and
Arraying
committed
Version 0.4.6
1 parent 421fa72 commit 752e095

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/main/java/de/arraying/kotys/JSONORM.java

+14-5
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,25 @@ T mapTo(JSON json, String... ignoredJSONKeys)
130130
if(!json.has(key)) {
131131
continue;
132132
}
133+
Class<?> type = field.getType();
133134
Object rawValue = json.object(key);
134135
Object value;
135136
if(rawValue instanceof JSON) {
136-
value = ((JSON) rawValue).marshal(field.getType());
137+
if(type.equals(JSON.class)) {
138+
value = rawValue;
139+
} else {
140+
value = ((JSON) rawValue).marshal(type);
141+
}
137142
} else if(rawValue instanceof JSONArray) {
138-
Class<?> fieldType = field.getType().getComponentType();
139-
if(fieldType.isPrimitive()) {
140-
throw new IllegalArgumentException("Array type " + fieldType + " is primitive");
143+
if(type.equals(JSONArray.class)) {
144+
value = rawValue;
145+
} else {
146+
Class<?> fieldType = type.getComponentType();
147+
if(fieldType.isPrimitive()) {
148+
throw new IllegalArgumentException("Array type " + fieldType + " is primitive");
149+
}
150+
value = ((JSONArray) rawValue).marshal(fieldType);
141151
}
142-
value = ((JSONArray) rawValue).marshal(fieldType);
143152
} else {
144153
value = rawValue;
145154
}

0 commit comments

Comments
 (0)