I am trying to convert my json string to java object and I am getting error
Exception in thread "main" java.lang.NoClassDefFoundError: com/fasterxml/jackson/annotation/JsonInclude$Value
at com.fasterxml.jackson.databind.cfg.MapperConfig.<clinit>(MapperConfig.java:45)
at com.fasterxml.jackson.databind.ObjectMapper.<init>(ObjectMapper.java:535)
at com.fasterxml.jackson.databind.ObjectMapper.<init>(ObjectMapper.java:452)
at com.allianz.cmis.util.ApacheHttpClientGet.main(ApacheHttpClientGet.java:65)
Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.annotation.JsonInclude$Value
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 4 more
Here is my json string and my code snippet
json string
{'ctpnsw': [{'abc' , 'def' }]}
Model
public class Fields {
private List<String> ctpnsw;
public List<String> getCtpnsw() {
return ctpnsw;
}
public void setCtpnsw(List<String> ctpnsw) {
this.ctpnsw = ctpnsw;
}
}
Java code
`ObjectMapper mapper = new ObjectMapper();
List<Fields> list = mapper.readValue(output, TypeFactory.defaultInstance().constructCollectionType(List.class,Fields.class));
System.out.println(list);`
Sorry late to party but Using below dependency solved my problem.
Attached link: https://github.com/jcustenborder/kafka-connect-spooldir/issues/156