Skip to content

Commit

Permalink
Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
k163377 committed Feb 2, 2025
1 parent cf7a44d commit f391a83
Showing 1 changed file with 1 addition and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ object ValueClassUnboxSerializer : StdSerializer<Any>(Any::class.java) {

override fun serialize(value: Any, gen: JsonGenerator, provider: SerializerProvider) {
val unboxed = value::class.java.getMethod("unbox-impl").invoke(value)

if (unboxed == null) {
provider.defaultSerializeNull(gen)
return
}

provider.defaultSerializeValue(unboxed, gen)
}
}
Expand All @@ -76,9 +70,7 @@ internal sealed class ValueClassSerializer<T : Any>(t: Class<T>) : StdSerializer
val unboxed = unboxMethod.invoke(value)
// As shown in the processing of the factory function, jsonValueGetter is always a static method.
val jsonValue: Any? = staticJsonValueGetter.invoke(null, unboxed)
jsonValue
?.let { provider.defaultSerializeValue(it, gen) }
?: provider.defaultSerializeNull(gen)
provider.defaultSerializeValue(jsonValue, gen)
}
}

Expand Down

0 comments on commit f391a83

Please sign in to comment.