Can not deserialize instance of SaleListDTO out of START_ARRAY token

Sofiane

The issue is i'm getting this error.

I have to simulate rest service call because it's being developed now by another team.

com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of com.egencia.service.invoiceaggregator.cache.SaleListDTO out of START_ARRAY token

Here is my jackson mapper bean

Jackson2ObjectMapperBuilder
                .json()
                .featuresToEnable(DeserializationFeature.UNWRAP_ROOT_VALUE, DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT)                                    .serializationInclusion(JsonInclude.Include.NON_NULL)
                .serializationInclusion(JsonInclude.Include.NON_EMPTY)
                .failOnUnknownProperties(false)
                .build();
@JsonRootName("list")
public class SaleListDTO {
    private SaleDTO[] list;
    public SaleDTO[] getList() {
        return list;
    }
    public void setList(SaleDTO[] list) {
        this.list = list;
    }
}

Here is the JsON file

{"list": [
    {
        "id": 111111,
        "currency": "EUR",
        "country": "ITA",
        "name": "Italy",
        "code": "IT"
    },...
]}

I have tested so many combinations but in vain. please help

Barath

Remove @JsonRootName("list").

Here is the working example :

@Getter
@Setter
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class SaleListDTO {

    @JsonProperty("list")
    private SaleDTO[] list;



}


@Getter
@Setter
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class SaleDTO {

    private int id;
    private String currency;
    private String country;
    private String name;
    private String code;   



}

Test Method:

@Test
    public void testConversion() throws JsonParseException, JsonMappingException, IOException{
        ObjectMapper mapper=new ObjectMapper();
        SaleListDTO dto=mapper.readValue(new File(PATH), SaleListDTO.class);
        System.out.println(dto.toString());
    }

Response :

SaleListDTO(list=[SaleDTO(id=111111, currency=EUR, country=ITA, name=Italy, code=IT), SaleDTO(id=22222, currency=IN, country=INDIA, name=CHENNAI, code=IT)])

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Can not deserialize instance of JsonGen out of START_ARRAY token : newbee

From Dev

Can not deserialize instance of Object out of START_ARRAY token

From Dev

Can not deserialize instance of Object out of START_ARRAY token

From Dev

Can not deserialize instance of my package out of START_ARRAY token

From Dev

Can not deserialize instance of java.util.HashMap out of START_ARRAY token

From Dev

Json Mapping Exception can not deserialize instance out of START_ARRAY token

From Dev

Java REST API: Can not deserialize instance of Object out of START_ARRAY token

From Dev

Ignore the "Can not deserialize instance of java.util.LinkedHashMap out of START_ARRAY token" error

From Dev

com.fasterxml.jackson.databind.exc.MismatchedInputException: Can not deserialize instance of object out of START_ARRAY token

From Dev

Convert JSON to Object throws JsonMappingException "Can not deserialize instance of class out of START_ARRAY token"

From Dev

Java REST API: Can not deserialize instance of Object out of START_ARRAY token

From Java

com.fasterxml.jackson.databind.exc.MismatchedInputException: Can not deserialize instance of object out of START_ARRAY token - JAVA

From Dev

com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of org.springframework.data.domain.Sort out of START_ARRAY token

From Dev

Can not serialize instance of class out of START_ARRAY token\n

From Dev

ObjectMapper fails to deserialize - cannot deserialize instance of .... out of START_ARRAY token

From Java

Jackson error: Cannot deserialize instance of `java.lang.String` out of START_ARRAY token

From Dev

Cannot deserialize instance of object out of START_ARRAY token in Spring Webservice

From Dev

com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of Object out of START_ARRAY token

From Dev

com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize out of START_ARRAY token

From Dev

JSON deserialization throwing exception - Can not deserialize instance of java.util.ArrayList out of START_OBJECT token

From Java

Can not deserialize instance of java.util.ArrayList out of START_OBJECT token

From Dev

Could not read JSON: Can not deserialize instance of hello.Country[] out of START_OBJECT token

From Dev

Can not deserialize instance of my.package.name.PlaceData[] out of START_OBJECT token

From Dev

JsonMappingException: Can not deserialize instance of java.lang.Integer out of START_OBJECT token

From Dev

Exception: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token at

From Dev

JsonMappingException: Can not deserialize instance of java.lang.Integer out of START_OBJECT token

From Dev

JsonMappingException: Can not deserialize instance of java.util.List out of START_OBJECT token

From Java

JsonMappingException: out of START_ARRAY token

From Dev

Exception: "org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.lang.String out of START_OBJECT token"

Related Related

  1. 1

    Can not deserialize instance of JsonGen out of START_ARRAY token : newbee

  2. 2

    Can not deserialize instance of Object out of START_ARRAY token

  3. 3

    Can not deserialize instance of Object out of START_ARRAY token

  4. 4

    Can not deserialize instance of my package out of START_ARRAY token

  5. 5

    Can not deserialize instance of java.util.HashMap out of START_ARRAY token

  6. 6

    Json Mapping Exception can not deserialize instance out of START_ARRAY token

  7. 7

    Java REST API: Can not deserialize instance of Object out of START_ARRAY token

  8. 8

    Ignore the "Can not deserialize instance of java.util.LinkedHashMap out of START_ARRAY token" error

  9. 9

    com.fasterxml.jackson.databind.exc.MismatchedInputException: Can not deserialize instance of object out of START_ARRAY token

  10. 10

    Convert JSON to Object throws JsonMappingException "Can not deserialize instance of class out of START_ARRAY token"

  11. 11

    Java REST API: Can not deserialize instance of Object out of START_ARRAY token

  12. 12

    com.fasterxml.jackson.databind.exc.MismatchedInputException: Can not deserialize instance of object out of START_ARRAY token - JAVA

  13. 13

    com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of org.springframework.data.domain.Sort out of START_ARRAY token

  14. 14

    Can not serialize instance of class out of START_ARRAY token\n

  15. 15

    ObjectMapper fails to deserialize - cannot deserialize instance of .... out of START_ARRAY token

  16. 16

    Jackson error: Cannot deserialize instance of `java.lang.String` out of START_ARRAY token

  17. 17

    Cannot deserialize instance of object out of START_ARRAY token in Spring Webservice

  18. 18

    com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of Object out of START_ARRAY token

  19. 19

    com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize out of START_ARRAY token

  20. 20

    JSON deserialization throwing exception - Can not deserialize instance of java.util.ArrayList out of START_OBJECT token

  21. 21

    Can not deserialize instance of java.util.ArrayList out of START_OBJECT token

  22. 22

    Could not read JSON: Can not deserialize instance of hello.Country[] out of START_OBJECT token

  23. 23

    Can not deserialize instance of my.package.name.PlaceData[] out of START_OBJECT token

  24. 24

    JsonMappingException: Can not deserialize instance of java.lang.Integer out of START_OBJECT token

  25. 25

    Exception: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token at

  26. 26

    JsonMappingException: Can not deserialize instance of java.lang.Integer out of START_OBJECT token

  27. 27

    JsonMappingException: Can not deserialize instance of java.util.List out of START_OBJECT token

  28. 28

    JsonMappingException: out of START_ARRAY token

  29. 29

    Exception: "org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.lang.String out of START_OBJECT token"

HotTag

Archive