Is there any out of the box way to deserialize a singleton json array into a java pojo of the same type?
for example, I would like the following json:
[{"eventId": "event1", "timestamp": 1232432132}]
to be deserialized into the following java POJO:
class Event {
  String eventId;
  long timestamp;
}
I tried using the following class:
class Event {
  String eventId;
  long timestamp;
  public Event(@JsonProperty("eventId") String event, 
               @JsonProperty("timestamp") long timestamp)
    //fields init
  }
  @JsonCreator
  public Event(List<Event> singletonList)
    //take first element in list and set its fields on this
  } 
but this fails with:
om.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of java.util.ArrayList out of FIELD_NAME token
I know I can wrap the Event POJO with some other class like this:
class EventWrapper {
   Event event;
   @JsonCreator   
   EventWrapper(List<Event> events) {
     this.event = events.get(0);
   }  
but I would like to avoid that (as well as avoid custom deserializer)
Any help will be much appreciated.
 
    