Hi, I'm playing around with Kotlin and am using Gs...
# getting-started
b
Hi, I'm playing around with Kotlin and am using Gson too. I'm trying to use Gson to convert an object that has a reference to a property with type KClass. Gson throws a Stackoverflow exception for this, does anyone have an idea why please?
m
How do you want Gson to serialize KClass?
b
I tried to write a typeadapter
class KClassTypeAdapter : JsonSerializer<KClass<*>>
that just returns the simplename but it's not being picked up by gson
m
AFAIK, Gson picks up Json(De)Serializers by raw type equality.
b
so would KClass<*> match KClass<out Marshaller>?
m
Sorry, by exact type equality. So no. (De)Serializers being wrapped into com.google.gson.internal.bind.TreeTypeAdapter.SingleTypeFactory.
b
hey forgot to say thanks for help, i was being a dope 🙂
🙂 1