This commit is contained in:
Xwite committed 2023-03-18 11:38:57 +08:00
1 parent 06034fd8e2
commit 7982c69958
8 files changed
+8 -12

No files matched your search

@@ -52,17 +52,20 @@ object SourceAnalyzer {
val documentContext = jsonPath.parse(inputStream)
try {
val items: List<Map<String, Any>> = documentContext.read("$")
items.map {
items.forEach {
val jsonItem = jsonPath.parse(it)
jsonToBookSource(jsonItem.jsonString()).getOrThrow()
jsonToBookSource(jsonItem.jsonString()).getOrThrow().let {
bookSources.add(it)
}
}
} catch (_: Exception) {
val item: Map<String, Any> = documentContext.read("$")
val jsonItem = jsonPath.parse(item)
mutableListOf(
jsonToBookSource(jsonItem.jsonString()).getOrThrow()
)
jsonToBookSource(jsonItem.jsonString()).getOrThrow().let {
bookSources.add(it)
}
}
bookSources
}.onFailure {
throw NoStackTraceException(appCtx.getString(R.string.wrong_format))
}