优化
This commit is contained in:
@@ -52,23 +52,20 @@ object SourceAnalyzer {
|
|||||||
val documentContext = jsonPath.parse(inputStream)
|
val documentContext = jsonPath.parse(inputStream)
|
||||||
try {
|
try {
|
||||||
val items: List<Map<String, Any>> = documentContext.read("$")
|
val items: List<Map<String, Any>> = documentContext.read("$")
|
||||||
for (item in items) {
|
items.map {
|
||||||
val jsonItem = jsonPath.parse(item)
|
val jsonItem = jsonPath.parse(it)
|
||||||
jsonToBookSource(jsonItem.jsonString()).getOrThrow().let {
|
jsonToBookSource(jsonItem.jsonString()).getOrThrow()
|
||||||
bookSources.add(it)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (_: Exception) {
|
} catch (_: Exception) {
|
||||||
val item: Map<String, Any> = documentContext.read("$")
|
val item: Map<String, Any> = documentContext.read("$")
|
||||||
val jsonItem = jsonPath.parse(item)
|
val jsonItem = jsonPath.parse(item)
|
||||||
jsonToBookSource(jsonItem.jsonString()).getOrThrow().let {
|
mutableListOf(
|
||||||
bookSources.add(it)
|
jsonToBookSource(jsonItem.jsonString()).getOrThrow()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
} catch (_: Exception) {
|
}.onFailure {
|
||||||
throw NoStackTraceException(appCtx.getString(R.string.wrong_format))
|
throw NoStackTraceException(appCtx.getString(R.string.wrong_format))
|
||||||
}
|
}
|
||||||
bookSources
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun jsonToBookSource(json: String): Result<BookSource> {
|
fun jsonToBookSource(json: String): Result<BookSource> {
|
||||||
|
|||||||
Reference in New Issue
Block a user