replayAPP
replayAPP

Reputation: 33

Jackson : concatenate several keys for a field

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

Answers (1)

Marco Burla
Marco Burla

Reputation: 24

Take a look to Jackson custom deserializer and @JsonDeserialize annotation. You can implement your own deserializer for this purpose.

Upvotes: 1

Related Questions