Creating an escaped JSON string from a Kotlin object

Hi. I need to create an escaped JSON string from a Kotlin object in order to load JSON into DynamoDB using Document API. Is there a method in Kotlin Serialization for this purpose?

What is the differences between JSON and escaped JSON?

Below is an example of an escaped JSON document. There are libraries for Java such as GSON and others to convert normal JSON into escaped JSON, but I suspect that there is a native method in Kotlin Serialization for that, which I couldn’t identify. There used to be something like stringify(), but it doesn’t seem to be any longer supported.

{   \"pdsType\": \"BaseDefaults\",   \"setName\": \"setA\",   \"coverages\": {     \"personalLiability\": \"200000\"   } }

kotlinx.serialization has a normal json generator. Not sure if it has an option to escape the quotation-marks.
That said the library is open source and it shouldn’t be to hard to just adapt it to your needs or you could open an issue with them, describing your usecase. There is a good chance that they will add this, but it might take a bit longer.
Also you could just use GSON. I’m not 100% sure how well it works with kotlin nullable types but AFAIK it is possible to use it with kotlin.