eclipse-vertx / eclipse-vertx/vertx-codegen
@DataObject does not handle json in String format when generating Converters
- Lingua principale
- Java
- Stelle
- 111
- Fork
- 89
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
### 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.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia dal percorso di generazione del convertitore fromJson di @DataObject e analizza come viene gestita la proprietà attributes di JsonObject. Riproduci il caso mostrato con un JSON String, quindi verifica che sia gli input JsonObject sia quelli String vengano mappati correttamente e che il codice generato corrisponda al comportamento richiesto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- java
- Ambito
- tooling
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100