Skip to content
Advertisement

JSON parse error: Cannot deserialize instance of ArrayList

I’m trying to send a JSON to a POST bodyRequest service to use this information as a Java ArrayList or something like that. When I try to do it, I receive a deserialize error

This is my JSON:

{information: [ {fields: “Periods Offered”, tables: “Courses”, columns: “Academic Level*”}, {fields: “Default Grading Basis*”, tables: “Courses”, columns: “Default Offering Percentage”}, {fields: “Allowed Locations”, tables: “Courses”, columns: “Allowed to Offer”} ] }

This is my POST bodyRequest service

JavaScript

My UpdateDataMapping class looks like:

JavaScript

This is my error:

.w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize instance of java.util.ArrayList<com.kastech.model.UpdateDataMapping> out of START_OBJECT token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of java.util.ArrayList<com.kastech.model.UpdateDataMapping> out of START_OBJECT token at [Source: (PushbackInputStream); line: 1, column: 1]]

If someone can help me I will appreciate it.

Advertisement

Answer

Your JSON example shows that your array is delivered inside an information object. You are seeing your current stack trace because the Jackson is unable to find an appropriate way to deserialize your request payload.

Either, you can change your request JSON to simply be a list

JavaScript

or you can have a POJO represent that information object

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement