Encoding example

Report a typo

What is the output of the following code?

@Serializable
class City(val name: String, val population: Int, val areaKm2: Double = 0.0)

val barcelona = City("Barcelona", 1700000, 101.4)

val json = Json { prettyPrint = false }

val jsonBarcelona = json.encodeToString(barcelona)
println(jsonBarcelona)

a)

{
    "name": "Barcelona",
    "population": 1700000
}

b)

{
    "name": "Barcelona",
    "population": 1700000,
    "areaKm2": 101.4
}

c)

{"name":"Barcelona","population":1700000,"areaKm2":101.4}

d)

{"name":"Barcelona","population":1700000}
Select one option from the list
___

Create a free account to access the full topic