Print JSON

Report a typo

The following program reads the name and the position of an employee from the standard input. Then, it prints this information in the JSON format (see the sample input and output).

Write the missing code for serializing the data and printing the relevant JSON string.

This task uses dependencies that may not be available in your local IDE. As a result, you may see compilation errors or unresolved references when running the code locally. This does not affect solution validation when you submit your solution to Hyperskill.

Sample Input 1:

Jack Peters,Engineer

Sample Output 1:

{"name":"Jack Peters","position":"Engineer"}
Write a program in Kotlin
import kotlinx.serialization.*
import kotlinx.serialization.json.*

@Serializable
data class Employee(val name: String, val position: String)

fun main() {
val (name, position) = readln().split(",")
val employee = Employee(name, position)
// Write your code here

}

Create a free account to access the full topic