You need to look at the constructors via reflectio...
# announcements
k
You need to look at the constructors via reflection.
g
Yes you right but problematic part is initialization of constructor
For example when I call clazz.constructors.first().parameters.first().name it gives variable name wrong
but I can clazz.declaredFields.first().name
it gives me field name correct. So how can I initialize that fields correctly
Example class Person(val name:String, val surname: String)
d
What is
clazz
? Is it
KClass
? What does it output?
g
fun <T> parse(json: String, clazz: Class<T>)
d
If you want proper result you need to use Kotlin reflection, i.e.
KClass
.
g
could you please give an example how to use properly ?
d