Title
b

boombastech

03/21/2017, 4:13 PM
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

miha-x64

03/21/2017, 4:17 PM
How do you want Gson to serialize KClass?
b

boombastech

03/21/2017, 4:19 PM
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

miha-x64

03/21/2017, 4:20 PM
AFAIK, Gson picks up Json(De)Serializers by raw type equality.
b

boombastech

03/21/2017, 4:22 PM
so would KClass<*> match KClass<out Marshaller>?
m

miha-x64

03/21/2017, 4:29 PM
Sorry, by exact type equality. So no. (De)Serializers being wrapped into com.google.gson.internal.bind.TreeTypeAdapter.SingleTypeFactory.
b

boombastech

04/13/2017, 1:20 PM
hey forgot to say thanks for help, i was being a dope 🙂
🙂 1