Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

com.fasterxml.jackson.databind.JsonMappingException: Duplicate creator property "id" (index 0 vs 1)

I use the library fasterxml to parse my data from my server. Since a couple of hours i started to get this error message. When i try to retrieve some json. I do not know why i get this message because it was working fine before. So if anyone could explain me what does that mean, it will be awesome. Thank you in advanced !

Caused by: com.fasterxml.jackson.databind.JsonMappingException: Duplicate creator property "id" (index 0 vs 1)
                                                                  at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:270)
                                                                  at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:245)
                                                                  at com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:143)
                                                                  at com.fasterxml.jackson.databind.DeserializationContext.findContextualValueDeserializer(DeserializationContext.java:406)
                                                                  at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.createContextual(CollectionDeserializer.java:164)
                                                                  at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.createContextual(CollectionDeserializer.java:25)
                                                                  at com.fasterxml.jackson.databind.DeserializationContext.handleSecondaryContextualization(DeserializationContext.java:653)
                                                                  at com.fasterxml.jackson.databind.DeserializationContext.findContextualValueDeserializer(DeserializationContext.java:408)

here my class :

@JsonIgnoreProperties(ignoreUnknown = true)
public class Dieser
    implements Serializable
{

  private static final long serialVersionUID = 8847499061681136159L;

  @JsonProperty("id")
  private long id;

  @JsonProperty("nickName")
  private String nickName;

  @JsonProperty("photo")
  private Photo photo;

  @JsonProperty("mail")
  private String mail;

  @JsonProperty("password")
  private String password;

  @JsonProperty("dateTime")
  private long dateTime;

  @JsonProperty("dieseCount")
  private int dieseCount;

  @JsonProperty("activateAccount")
  public boolean activateAccount;

  @JsonProperty("activateDateTime")
  public long activateDateTime;

  public Dieser()
  {
  }

}
like image 367
Safety Avatar asked Oct 29 '25 01:10

Safety


1 Answers

Ok I got it. Actually the problem was on another business object where I had a JSON property duplicated as id.

    @JsonCreator
public Extra(@JsonProperty("id") String id, @JsonProperty("id") ExtraType type, @JsonProperty("label") String label,
    @JsonProperty("points") int points)
{
  this.id = id;
  this.type = type;
  this.label = label;
  this.points = points;
}

The stack trace wasn't really explicit about where the problem come from. The exception was raised each time i needed to parse any object, that's why i didn't see it at the first time.

This kind of problem waste me a lot of time. Hope that could help someone in the future.

like image 200
Safety Avatar answered Oct 31 '25 17:10

Safety