Can not deserialize instance of java.lang.String out of START_OBJECT token
You're mapping this JSON
{ "id": 2, "socket": "0c317829-69bf-43d6-b598-7c0c550635bb", "type": "getDashboard", "data": { "workstationUuid": "ddec1caa-a97f-4922-833f-632da07ffc11" }, "reply": true}
that contains an element named data
that has a JSON object as its value. You are trying to deserialize the element named workstationUuid
from that JSON object into this setter.
@JsonProperty("workstationUuid")public void setWorkstation(String workstationUUID) {
This won't work directly because Jackson sees a JSON_OBJECT, not a String.
Try creating a class Data
public class Data { // the name doesn't matter @JsonProperty("workstationUuid") private String workstationUuid; // getter and setter}
the switch up your method
@JsonProperty("data")public void setWorkstation(Data data) { // use getter to retrieve it
If you do not want to define a separate class for nested json , Defining nested json object as JsonNode should work ,for example :
{"id":2,"socket":"0c317829-69bf-43d6-b598-7c0c550635bb","type":"getDashboard","data":{"workstationUuid":"ddec1caa-a97f-4922-833f-632da07ffc11"},"reply":true}@JsonProperty("data") private JsonNode data;
Data content is so variable, I think the best form is to define it as "ObjectNode" and next create his own class to parse:
Finally:
private ObjectNode data;