Is there a simple way to deserialize a list of strings into a single string?
For example, I would have this JSON:
{
"stringList": [
"somethingElse"
],
"simpleString": "something",
}
I would like it to be deserialized into this POJO:
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class AClass {
@JsonProperty("stringList")
private String justAString;
@JsonProperty("simpleString")
private String someString;
}
I would like to mention that it is certain that the list has only one item and have no control over how it is generated. Is the only way to go a custom deserializer for the justAString field?
EDIT I would like to use ObjectMapper class from Jackson if it is possible