My example code is below:
fun main(args: Array<String>) {
val testData = mapOf<String, Any>(
"name" to "albert",
"age" to 26,
"work" to listOf("1", "2", "3")
)
var value = JSON.stringify(testData, { _, value -> value.toString() }, 2)
println(value)
}
The result is "{name=albert, age=26, work=[1, 2, 3]}"
.
Seems it misses all the double quotes around the property name and string value.
I'm using KotlinJS
rather than Kotlin
So, how to solve this?