Reputation: 33
Is it possible when deserializing my Json with Jackson to link several json keys to a single variable of my Java object?
I receive from my Json the attributes profil_id
,trimestre_id
and ap_id
and I would like to insert all of them in my variable idApp
of my class App
.
Example:
profil_id = "AA"
trimestre_id = "BB"
ap_id = "CC"
will return idApp = "AABBCC"
For now, my Java class looks like but it returns only idApp = "AA"
:
public class App {
@Id
@JsonAlias({"profil_id","trimestre_id","ap_id"})
@Column(name = "id_app")
private String idApp;
Thanks.
Upvotes: 2
Views: 368
Reputation: 24
Take a look to Jackson custom deserializer and @JsonDeserialize annotation. You can implement your own deserializer for this purpose.
Upvotes: 1