https://kotlinlang.org logo
Title
t

Tobias Preuss

04/11/2018, 9:37 AM
Hi. I want to try Klaxon from a Java class and noticed that
new Klaxon().parse<>
(the
.parse()
function) is not available as stated in the docs. How am I supposed to read a JSON string?
g

gildor

04/12/2018, 2:02 AM
Maybe you could just create a kotlin function that will wraps call of this method with reified generic:
@file:JvmName("KlaxonJava")
fun Klaxon.parse(cls: Class<T>): T  {
   return parse<T>()
}
// Call from Java
KlaxonJava.parse(new Klaxon(), SomeClass.java)
Not sure that my implementation is correct, but just a general idea