I have a scenario where I need to deserialise a JSON array to a list of strings.
My class is:
public class Pojo {
private String message;
private ArrayList<String> details;
}
JSON payload:
{
"message":"some value",
"details":[]
}
If I try to deserialise the below JSON, it works:
{
"message":"working example",
"details": [
"First element of the array",
"Second element"
]
}
In this case:
details = ["First element of the array", "Second element"]
If the array contains JSON objects as elements it will fail with MismatchedInputException:
{
"message":"working example",
"details":[
{"First":"Value"},
"Second element"
]}
For the second example, I'm expecting
details = ["{\"First\":\"Value\"}", "Second element"]
Is there a quick way to do this?