I have looked for other post in stack overflow but none of them work for me. Here is the piece of code:
public class Forward implements Serializable {
private List<String> freq;
public List<String> getFreq() {
System.out.println("Print Freq::: --> " + freq);
return freq;
}
public void setFreq(List<String> freq) {
this.freq = freq;
}
}
The JSON string is:
{"forward":[{"freq":"78000000"}]}
My mapper is:
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
String jsonString = mapper.writeValueAsString(result);
If I remove List freq and change to String freq it works but my JSON can contain one or more freq so I need to create a List.I get exception as:
Can not deserialize instance of java.util.ArrayList out of VALUE_STRING token at [Source: org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream