I have a Json string like below
{
"EngineData": [
{
"make": "Toyota",
"transmission": "Manual",
"fuel": "Petrol"
},
{
"make": "GMC",
"transmission": "Auto",
"fuel": "Petrol"
},
{
"make": "Honda",
"transmission": "Manual",
"fuel": "Petrol"
}
]
}
I have the POJO defined like below
@JsonIgnoreProperties(ignoreUnknown = true)
public class EngineData implements Serializable {
@JsonProperty("make")
private String make;
@JsonProperty("transmission")
private String transmission;
@JsonProperty("fuel")
private String fuel;
//getters and setters
}
I wanted to read it to List<EngineData>
I wrote the following but it doesn't read the String to a EngineData list
List<EngineData> engineDataList =null;
ObjectMapper mapper = new ObjectMapper();
engineDataList = mapper.readValue(myJsonString, new TypeReference<List<EngineData>>() {
});
Not sure whats wrong in this