优化
This commit is contained in:
@@ -222,16 +222,25 @@ data class BookSource(
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
|
private val gson = GSON.newBuilder()
|
||||||
|
.registerTypeAdapter(ExploreRule::class.java, ExploreRule.jsonDeserializer)
|
||||||
|
.registerTypeAdapter(SearchRule::class.java, SearchRule.jsonDeserializer)
|
||||||
|
.registerTypeAdapter(BookInfoRule::class.java, BookInfoRule.jsonDeserializer)
|
||||||
|
.registerTypeAdapter(TocRule::class.java, TocRule.jsonDeserializer)
|
||||||
|
.registerTypeAdapter(ContentRule::class.java, ContentRule.jsonDeserializer)
|
||||||
|
.registerTypeAdapter(ReviewRule::class.java, ReviewRule.jsonDeserializer)
|
||||||
|
.create()
|
||||||
|
|
||||||
fun fromJson(json: String): Result<BookSource> {
|
fun fromJson(json: String): Result<BookSource> {
|
||||||
return GSON.fromJsonObject(json)
|
return gson.fromJsonObject(json)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun fromJsonArray(json: String): Result<List<BookSource>> {
|
fun fromJsonArray(json: String): Result<List<BookSource>> {
|
||||||
return GSON.fromJsonArray(json)
|
return gson.fromJsonArray(json)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun fromJsonArray(inputStream: InputStream): Result<List<BookSource>> {
|
fun fromJsonArray(inputStream: InputStream): Result<List<BookSource>> {
|
||||||
return GSON.fromJsonArray(inputStream)
|
return gson.fromJsonArray(inputStream)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,12 +22,6 @@ val GSON: Gson by lazy {
|
|||||||
)
|
)
|
||||||
.registerTypeAdapter(Int::class.java, IntJsonDeserializer())
|
.registerTypeAdapter(Int::class.java, IntJsonDeserializer())
|
||||||
.registerTypeAdapter(String::class.java, StringJsonDeserializer())
|
.registerTypeAdapter(String::class.java, StringJsonDeserializer())
|
||||||
.registerTypeAdapter(ExploreRule::class.java, ExploreRule.jsonDeserializer)
|
|
||||||
// .registerTypeAdapter(SearchRule::class.java, SearchRule.jsonDeserializer)
|
|
||||||
// .registerTypeAdapter(BookInfoRule::class.java, BookInfoRule.jsonDeserializer)
|
|
||||||
// .registerTypeAdapter(TocRule::class.java, TocRule.jsonDeserializer)
|
|
||||||
// .registerTypeAdapter(ContentRule::class.java, ContentRule.jsonDeserializer)
|
|
||||||
// .registerTypeAdapter(ReviewRule::class.java, ReviewRule.jsonDeserializer)
|
|
||||||
.disableHtmlEscaping()
|
.disableHtmlEscaping()
|
||||||
.setPrettyPrinting()
|
.setPrettyPrinting()
|
||||||
.create()
|
.create()
|
||||||
|
|||||||
Reference in New Issue
Block a user