-1

I have this error:

JSON parse error: Cannot deserialize instance of com.asc.skyalign.service.dto.TaskDataDTO out of START_ARRAY token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of com.asc.skyalign.service.dto.TaskDataDTO out of START_ARRAY token\n at [Source: (PushbackInputStream); line: 10, column: 21] (through reference chain: com.asc.skyalign.service.dto.WorkOrderDTO["taskDataList"])

When post Json API, this is my request :

 { "siteLocationLat": "35.123415", "workOrderID": "WO-1rmrud5gkdj4r0n6", "siteId": "NNA-12312312311", "siteAcessNotes": "No notes", "siteLocationLong": "128.910283984", "assignedTo": "[email protected]", "timeStamp": 1596738379102, "email": "[email protected]", "taskDataList": [ { "roll": "2.0", "azimuth": "120.0", "tilt": "9.0", "sectorLocationLat": "35.123451", "amtImei": "35800121213", "wakeuUpInterval": "1440", "sectorID": "NNA-12312312311-1", "sectorLocationLong": "128.123123", "taskName": "Install AMT Sector A", "taskDescription": "Install AMT on Back of the Antenna" } ] } 

My WorkOrderDto is:

 public class WorkOrderDTO implements Serializable { private List<TaskDataDTO> taskDataList=new ArrayList<TaskDataDTO>(); public List<TaskDataDTO> getTaskDataList() { return taskDataList; } public void setTaskDataList(TaskDataDTO taskDataDTO) { this.taskDataList.add(taskDataDTO); } } 

and my WorkOrder Entity is :

public class WorkOrder implements Serializable { private List<TaskData> taskDataList=new ArrayList<TaskData>(); public List<TaskData> getTaskDataList() { return taskDataList; } public void setTaskDataList(TaskData taskData) { taskDataList.add(taskData); } } 

when run my application and request the api and before arrived my controller i see this Exception in postman body :

JSON parse error: Cannot deserialize instance of com.asc.skyalign.service.dto.TaskDataDTO out of START_ARRAY token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of com.asc.skyalign.service.dto.TaskDataDTO out of START_ARRAY token\n at [Source: (PushbackInputStream); line: 10, column: 21] (through reference chain: com.asc.skyalign.service.dto.WorkOrderDTO["taskDataList"])

and this error in Java Idea terminal :

Bad Request: JSON parse error: Cannot deserialize instance of com.asc.skyalign.service.dto.TaskDataDTO out of START_ARRAY token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of com.asc.skyalign.service.dto.TaskDataDTO out of START_ARRAY token at [Source: (PushbackInputStream); line: 10, column: 21] (through reference chain: com.asc.skyalign.service.dto.WorkOrderDTO["taskDataList"])

1
  • You will need to include the task data dto class here to be helpful - that’s where your error is Commented Feb 7, 2021 at 10:47

1 Answer 1

0
public void setTaskDataList(TaskDataDTO taskDataDTO) { this.taskDataList.add(taskDataDTO); } 

is strange for me, you say that you set the task data list, and you have a taskDataDto in parameter that you add it to the list. WorkOrderDto taskdatalist getter and setter should be something like this

@JsonProperty("taskDataList") public List<TaskDataList> getTaskDataList() { return taskDataList; } @JsonProperty("taskDataList") public void setTaskDataList(List<TaskDataList> value) { this.taskDataList = value; } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.