Skip to content

Instantly share code, notes, and snippets.

@zehpatricio
Created March 9, 2022 20:25
Show Gist options
  • Save zehpatricio/e58763ab3dfc56c5316675eb73b413a9 to your computer and use it in GitHub Desktop.
Save zehpatricio/e58763ab3dfc56c5316675eb73b413a9 to your computer and use it in GitHub Desktop.
import kotlinx.serialization.*
import kotlinx.serialization.json.*
@Serializable
class Endereco(
val planeta: String,
val galaxia: String,
)
@Serializable
class Aluno(
val nome: String,
val media: Float,
val endereco: Endereco,
)
fun main() {
val endereco = Endereco("Tatooine", "Outer Rim")
val aluno = Aluno("Luke Skywalker", 9.8f, endereco)
println(Json.encodeToString(aluno))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment