Skip to content

Instantly share code, notes, and snippets.

@iamitshri
Created March 27, 2019 16:27
Show Gist options
  • Save iamitshri/d77be856a6ad1d36f0bc4fc6017e80d5 to your computer and use it in GitHub Desktop.
Save iamitshri/d77be856a6ad1d36f0bc4fc6017e80d5 to your computer and use it in GitHub Desktop.
Read json file
public static <E> List<E> readJsonFile(TypeReference<List<E>> typeReference, String jsonFileName) {
List<E> list = new ArrayList<>();
ObjectMapper mapper = new ObjectMapper();
InputStream inputStream = TypeReference.class.getResourceAsStream(jsonFileName);
try {
list = mapper.readValue(inputStream, typeReference);
} catch (IOException e) {
e.printStackTrace();
}
return list;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment