From adffd87df0a6ab5a19932cfd301188be921ea63e Mon Sep 17 00:00:00 2001 From: Luna712 <142361265+Luna712@users.noreply.github.com> Date: Mon, 8 Jun 2026 12:40:15 -0600 Subject: [PATCH] Fix kotlinx serialization in parseJson It doing runCatching on the Result itself, that results in the serializer always returning null. Just do what we do everywhere else here also, getContextual doesn't throw anything. --- .../kotlin/com/lagradost/cloudstream3/utils/AppUtils.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/utils/AppUtils.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/utils/AppUtils.kt index 3d9cc8944f5..6233fd82018 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/utils/AppUtils.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/utils/AppUtils.kt @@ -60,9 +60,8 @@ object AppUtils { inline fun parseJson(value: String): T { // @Serializable generates a serializer at compile time; contextual serializers are // registered manually in serializersModule, we need both to support all cases - val serializer = runCatching { serializer() }.runCatching { - json.serializersModule.getContextual(T::class) - }.getOrNull() + val serializer = runCatching { serializer() }.getOrNull() + ?: json.serializersModule.getContextual(T::class) // Prefer Kotlin Serialization over Jackson if (serializer != null) { @@ -94,4 +93,4 @@ object AppUtils { null } } -} \ No newline at end of file +}