Cannot deserialize value of type java.lang.String from Object value

69 Views Asked by At

I have Big JSON payload and I am trying parse this Json into Target class. in the target class there is one filed which is String type. But JSON payload will have Object structure. When I parse this payload, Object Mapper throws an exception as can not deserialize from Object to String. Below is the class.

Class Properties{
String url;
String requestType;
String payload;
}

Sample Payload:     
"properties": {
        "url": "https://stackoverflow.com/questions",
        "requestType": "GET",
        "payload": {
            "testId": 123,
            "testName": "API",
            "description": "Call GET Request",
            "testCode": "STACKD001"
        }
    }

When I parse this payload it throws Cannot deserialize value of type java.lang.String from Object value for the property payload.

How to achieve without changing the JSON payload? I want the payload as String.

My JSON payload is much more complex than the sample one I provided here.

Note: I don't have control to add any ignore property to the Class property as it is generated from dependent module.

0

There are 0 best solutions below