toJsonString

Converts this object to its JSON string representation.

Uses the pre-configured JsonSerializer to serialize the object.

Receiver

The object to serialize. Can be any type.

Return

The JSON string representation of the object.

Throws

JsonProcessingException

if serialization fails.

Example:

val user = mapOf("name" to "John", "age" to 30)
val json = user.toJsonString() // {"name":"John","age":30}