• Register
0 votes
6k views

Problem :

I am trying to POST a List of custom objects but i am getting exception as below
can not deserialize instance of java.util.arraylist out of start_object token
6 5 3
6,930 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

The issue  seems to be the JSON  it is not actually a JSON Array that would look like this:

[
    {
        "name": "Test order1",
        "detail": "ahk ks"
    },
    {
        "name": "Test order2",
        "detail": "Fisteku"
    }
]

Since you are not controlling the exact process of deserialization (RestEasy does) 

1) would be to simply inject the JSON as a String and then take control of the deserialization process using bellow code:

Collection<COrder> readValues = new ObjectMapper().readValue(
    jsonAsString, new TypeReference<Collection<COrder>>() { }
);

You may loose a bit of the convenience of not able to do that yourself, but you would easily sort out the problem.

2)  if you cannot change the JSON - would be to construct a wrapper to fit the structure of your JSON input - and use that instead of Collection<COrder>.

Further Readings:

https://github.com/Netflix/conductor/issues/517

9 7 4
38,600 points

Related questions

0 votes
1 answer 349 views
349 views
Problem : I want to POST the List of custom objects. My JSON in a request body is as below : {     "collection": [         {             "name": "Test ordert1",             "detail": "ahk ksa"         },         {             "name": "Test ... } But I am facing below error: &ldquo;Can not deserialize instance of java.util.arraylist out of start_object token&rdquo; How can I fix the above error?
asked Jan 21, 2020 jwilliam 3.9k points
0 votes
1 answer 16 views
16 views
Problem : I am trying to POST a List of custom objects but i am getting exception as below can not deserialize instance of java.util.arraylist out of start_object token
asked Mar 6 Wafa Abu Yousef 6.1k points
0 votes
1 answer 57 views
0 votes
1 answer 594 views
594 views
I am getting an issue where my deployable jar hits an exception : can not deserialize instance of java.lang.string out of start_object token
asked Oct 23, 2019 peterlaw 6.9k points
0 votes
1 answer 659 views
659 views
Problem : I am very new to Spring Boot. I am learning to write code in Spring Boot. I have written my first Spring Boot code as below @RequestMapping(value = "/bar/foo", method = RequestMethod.GET) public MyResponseEntity<foo> foo() { Foo model; ... return ... .core</groupId> <artifactId>jackson-databind</artifactId> <version>2.4.3</version> </dependency> How can I fix above Spring Boot exception?
asked Feb 29, 2020 mphil 2.3k points
0 votes
1 answer 410 views
0 votes
1 answer 30 views
30 views
Problem : Is there any annotation that needs to be added to be able to remove this issue: No string-argument constructor/factory method to deserialize from string value.
asked Mar 6 Wafa Abu Yousef 6.1k points
0 votes
1 answer 7.4K views
7.4K views
Problem : I am running into the json parsing issue when using a ObjectMapper class from a com.fasterxml.jackson.databind package, and a error that I am getting is: com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of com.graybar.utilities.ups.beans. ... no control over a data I receive. Is there any annotation that needs to be added to be able to remove this issue?
asked Jan 18, 2020 jwilliam 3.9k points
0 votes
1 answer 33 views
33 views
Problem: messagebodywriter not found for media type=application/json.
asked Feb 17 charles mathews 5.5k points
0 votes
1 answer 14 views
14 views
Problem http status 403 - expected csrf token not found. has your session expired?
asked Feb 9 charles mathews 5.5k points