This is my JSON Array :-
[
{
\"firstName\" : \"abc\",
\"lastName\" : \"xyz\"
},
{
\"firstName\" : \"pqr\",
\"
I made a method to do this below called jsonArrayToObjectList
. Its a handy static class that will take a filename and the file contains an array in JSON form.
List items = jsonArrayToObjectList(
"domain/ItemsArray.json", Item.class);
public static List jsonArrayToObjectList(String jsonFileName, Class tClass) throws IOException {
ObjectMapper mapper = new ObjectMapper();
final File file = ResourceUtils.getFile("classpath:" + jsonFileName);
CollectionType listType = mapper.getTypeFactory()
.constructCollectionType(ArrayList.class, tClass);
List ts = mapper.readValue(file, listType);
return ts;
}