Fix json null string

This commit is contained in:
Koitharu
2020-04-26 20:25:46 +03:00
parent 5af32898f8
commit 34acf5bb55
2 changed files with 6 additions and 3 deletions

View File

@@ -7,6 +7,7 @@ import org.koitharu.kotatsu.core.model.Manga
import org.koitharu.kotatsu.core.model.MangaChapter
import org.koitharu.kotatsu.core.model.MangaSource
import org.koitharu.kotatsu.core.model.MangaTag
import org.koitharu.kotatsu.utils.ext.getStringOrNull
import org.koitharu.kotatsu.utils.ext.map
import org.koitharu.kotatsu.utils.ext.safe
@@ -44,12 +45,12 @@ class MangaIndex(source: String?) {
Manga(
id = json.getLong("id"),
title = json.getString("title"),
altTitle = json.getString("title_alt"),
altTitle = json.getStringOrNull("title_alt"),
url = json.getString("url"),
source = source,
rating = json.getDouble("rating").toFloat(),
coverUrl = json.getString("cover"),
description = json.getString("description"),
description = json.getStringOrNull("description"),
tags = json.getJSONArray("tags").map { x ->
MangaTag(
title = x.getString("title"),

View File

@@ -21,4 +21,6 @@ fun <T> JSONArray.mapIndexed(block: (Int, JSONObject) -> T): List<T> {
result.add(block(i, jo))
}
return result
}
}
fun JSONObject.getStringOrNull(name: String): String? = opt(name)?.toString()