我正在尝试将json字符串转换为java对象,但出现错误
这是我的json字符串和我的代码段
json字串{'ctpnsw': [{'abc' , 'def' }]}
模型
public class Fields {
private List<String> ctpnsw;
public List<String> getCtpnsw() {
return ctpnsw;
}
public void setCtpnsw(List<String> ctpnsw) {
this.ctpnsw = ctpnsw;
}
}
Java代码
ObjectMapper mapper = new ObjectMapper(); List<Fields> list = mapper.readValue(output, TypeFactory.defaultInstance().constructCollectionType(List.class,Fields.class)); System.out.println(list);
最佳答案
如何将此添加到您的pom.xml
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
</dependency>
关于java - java.lang.ClassNotFoundException : com. fastxml.jackson.annotation.JsonInclude $ Value,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35569092/