You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While JsonElement.toString() produces string with escaped double-quote character, JsonElement.content.toString() produces unescaped and unquoted string
To Reproduce
val secret ="""338="}ha2"""val j = json {
"secret" to JsonLiteral(secret)
}
println(j["secret"]) // "338=\"}ha2"println(j["secret"]?.content) // 338="}ha2
Expected behavior
Special characters (") are escaped in JsonLiteral constructor.
Other possible solutions: discourage work with .content.
It is unclear whether .content should be quoted.
Environment
Kotlin version: 1.3.70
Library version: 0.20.0
Kotlin platforms: all
The text was updated successfully, but these errors were encountered:
After investigation, it seems like non-escaped content does not cause any troubles when used by kotlinx.serialization. The only harmful behaviour may be when a user serializes JsonElement by hand expecting it to be fully-compliant (-> escaped). Added a note to clarify it
Addresses #773
After investigation, it seems like non-escaped content does not cause any troubles when used by kotlinx.serialization. The only harmful behaviour may be when a user serializes JsonElement by hand expecting it to be fully-compliant (-> escaped). Added a note to clarify it
Addresses #773
Describe the bug
While
JsonElement.toString()
produces string with escaped double-quote character,JsonElement.content.toString()
produces unescaped and unquoted stringTo Reproduce
Expected behavior
Special characters (") are escaped in JsonLiteral constructor.
Other possible solutions: discourage work with
.content
.It is unclear whether
.content
should be quoted.Environment
The text was updated successfully, but these errors were encountered: