I have the below json string that comes from the db. I have to read the json and return the equivalent java class. Json String:
{
"Items": [
{
"mode": "old",
"processing": [
"MANUAL"
]
},
{
"mode": "new",
"processing": [
"AUTO"
]
}
]
}
Items class
public class Items {
private String mode;
private List<String> processing;
public String getMode() {
return mode;
}
public void setMode(String mode) {
this.mode = mode;
}
public List<String> getProcessing() {
return processing;
}
public void setProcessing(List<String> processing) {
this.processing = processing;
}
}
Here I am trying to read the above json string array using ObjectMapper.readValue() method and convert it to List.
I have tried with the below code
ObjectMapper mapper=new ObjectMapper();
List<Items> actions = Arrays.asList(mapper.readValue(json, Items[].class));
and getting the error
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "actions" (class ), not marked as ignorable (2 known properties: "mode", "processing"])at [Source: (String)"{
"items":[
{
"mode": "old",
"processing": ["MANUAL"]
},
{
"mode": "new",
"processing": ["AUTO"]
}
]
}"; line: 2, column: 13]