Last active
July 26, 2022 15:07
-
-
Save stella6767/3778d828a62c8cddd7b5d4da81f50008 to your computer and use it in GitHub Desktop.
json object Array file reader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun <T> readJsonArrayFile(filePath: String): List<Map<*, *>?>? { | |
val mapper = ObjectMapper() | |
//val readFileAsString = readFileAsString(filePath) | |
//println(readFileAsString) | |
val myObjects = mapper.readValue(File(filePath), object : TypeReference<List<Map<*, *>?>>() {}) | |
// for (obj in myObjects) { | |
// println(obj) | |
// } | |
return myObjects | |
} | |
private fun readFileAsString(filePath: String): String { | |
return String(Files.readAllBytes(Paths.get(filePath))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment