Ktor Json

Ktor HttpClient JSON support is a feature that enables automatic serialization and deserialization of JSON data sent from the client or received from the server into Kotlin data classes.

                        val response: HttpResponse = client.post("http://${ip}:{port}/product/productupdate") {
            
  contentType(ContentType.Application.Json)
            
   setBody(
      mapOf(
         "Name" to productName,
         "Color" to productColor
           )
       )
}
                    

client.post(..)

HTTP POST request

contentType(ContentType.Application.Json)

The type of content to be sent is JSON

Json data

Data to be sent as JSON.

                        setBody(
      mapOf(
         "Name" to productName,
         "Color" to productColor
           )
       )