-
Notifications
You must be signed in to change notification settings - Fork 92
Description
Version
3.9.2
Context
When @'DataObject' is generated with its fromJson method objects that are import io.vertx.core.json.JsonObject only accept JsonObject as valid option for mapping. Example generated constructor:
private JsonObject attributes;
For this property following code is generated:
case "attributes":
if (member.getValue() instanceof JsonObject) {
obj.setAttributes(((JsonObject)member.getValue()).copy());
}
break;
Generated code should be like:
case "attributes":
if (member.getValue() instanceof JsonObject) {
obj.setAttributes(((JsonObject)member.getValue()).copy());
} else if (member.getValue() instanceof String) {
obj.setAttributes(new JsonObject(member.getValue()));
}
break;
If for example from DB I get a String field that has JSON formating this property will never get mapped. On the other hand if this POJO is generated by Jackson function this field with get mapped.
SomeDTO someDTO = json.mapTo(SomeDTO.class);
Extra
Is this something that was intended or just wasn't considered. In my eyes this is a standard approach as vertx json wrapper accepts String as valid for when generating Json objects. I can submit a PR if we agree to go with this.