Data classes to parse JSON

Hello. To parse JSON with kotlinx.serialization I use data classes. How this structure could be improved?

@Serializable
data class Parent(
    @SerialName("Parent")
    val someClass: SomeClass
)

@Serializable
data class SomeClass(
    @SerialName("SpaceShip")
    val ship: String,
    @SerialName("Mark")
    val mark: Int
)

Main code:

fun getSomeClass(inputStream: InputStream): SomeClass {
    val json = Json(JsonConfiguration.Stable)
    val jsonString = Scanner(inputStream).useDelimiter("\\A").next()
    val parent = json.parse(Parent.serializer(), jsonString)
    return parent.someClass
}

Is it possible to make a nested data class or to use some kind of Any type and act like in Javascript? There can be a lot of unnecessary data in JSON responce and some of important are within 4+ level from top. Is there a kind of fast adapter mechanism persists?

Due to the statically typed nature of Kotlin, no it is not possible.
Also that’s not only for Kotlin, but for every statically typed language.

Yes, I know. Don’t like to spend much time with non-primitive types. But maybe there is a way to short the code?

Not much aside from naming the fields the same way you want them in the json!
Have a look at many classes I wrote here, maybe you can find something…

I think, I saw something like this here