I have a json file like this :
[
{
"Teacher Code": "1",
"Teacher Name": "Papadopoulos",
"MaxHoursPerDay":5,
"MaxHoursPerWeek":18,
"Teacher Lessons": [
"Fysikh Agwgh"
]
},
{
"Teacher Code": "2",
"Teacher Name": "Nikolaou",
"MaxHoursPerDay":4,
"MaxHoursPerWeek":8,
"Teacher Lessons": [
"Thriskeytika"
]
},
{
"Teacher Code": "3",
"Teacher Name": "Anastasopoulou",
"MaxHoursPerDay":4,
"MaxHoursPerWeek":18,
"Teacher Lessons": [
"Ksenh Glwssa 1"
]
}...
and I want to iterate through that file and create java objects using jackson objectMapper and store those items in an arrayList.Here is what I have tried:
ObjectMapper mapper = new ObjectMapper();
File file = new File("Teachers.txt");
ArrayList<Teacher> tList = mapper.readValue(file, new TypeReference<ArrayList<Teacher>>(){};
But is shows me the error: type TypeReference does not take parameters. Whats the best way to do this without knowing the length of the json file?