diff --git a/korlibs-serialization/src/korlibs/io/serialization/json/Json.kt b/korlibs-serialization/src/korlibs/io/serialization/json/Json.kt index c88335c..05cb49e 100644 --- a/korlibs-serialization/src/korlibs/io/serialization/json/Json.kt +++ b/korlibs-serialization/src/korlibs/io/serialization/json/Json.kt @@ -245,7 +245,7 @@ open class Json { b.append('"') for (c in str) { when (c) { - '\\' -> b.append("\\\\"); '/' -> b.append("\\/"); '\'' -> b.append("\\'") + '\\' -> b.append("\\\\"); '/' -> b.append("\\/"); '"' -> b.append("\\\""); '\b' -> b.append("\\b"); '\u000c' -> b.append("\\f") '\n' -> b.append("\\n"); '\r' -> b.append("\\r"); '\t' -> b.append("\\t") else -> b.append(c) diff --git a/korlibs-serialization/test/korlibs/io/serialization/json/JsonTest.kt b/korlibs-serialization/test/korlibs/io/serialization/json/JsonTest.kt index 4e8c5b7..b15f47e 100644 --- a/korlibs-serialization/test/korlibs/io/serialization/json/JsonTest.kt +++ b/korlibs-serialization/test/korlibs/io/serialization/json/JsonTest.kt @@ -46,4 +46,12 @@ class JsonTest { fun decodeUnicode() { assertEquals("aeb", Json.parse(""" "a\u0065b" """)) } + + @kotlin.test.Test + fun stringify1(){ + assertEquals( + """{"str":"'","int":1,"bool":true}""", + Json.stringify(Json.parse("""{"str":"'","int":1,"bool":true}""")) + ) + } }