I have this JSON example
{ "name": "custom_text" }
My Object look like
public class NameObj {
private String name;
}
And with readValue() method from Jackson can deserialized my json into NameObj.
The real problem is when i don't have "name"
{ [ "custom_text" ] }
How create object in this case? And deserialization is same?
In the example { "names" : [ "custom_text" ] } it does not really matter if you represent the [ "custom_text" ] as list or array but if you choose the latter, it would rather be String[] instead of Array[]. Also mind the type erasure if you choose List String . Then you have to use e.g. TypeReference helpers.
Answer by mle
List String work for me. Thank you mle