Skip to content

Commit 3e65bfe

Browse files
committed
Adding new method in JsonUtils
1 parent 30cd409 commit 3e65bfe

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/main/java/uk/co/evoco/webdriver/utils/JsonUtils.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,18 @@ public static <T> T fromFile(File file, Class<T> type) throws IOException {
4949
return new ObjectMapper().readValue(file, type);
5050
}
5151

52+
/**
53+
*
54+
* @param file json file
55+
* @param type target class type of collection
56+
* @param <T> generic type
57+
* @return generic class for mapper
58+
* @throws IOException if file cannot be found
59+
*/
60+
public static <T> T fromFile(File file, TypeReference<T> type) throws IOException {
61+
return new ObjectMapper().readValue(file, type);
62+
}
63+
5264
/**
5365
* Deserialize a JSON from a File to a given class type
5466
* @param jsonStream json stream

0 commit comments

Comments
 (0)