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
In accordance with the JSON specification, it is required that any string value be enclosed in quotes. However, when I attempt to parse inputs containing unquoted string values into a JsonElement, I observe that the resulting JSON tree contains malformed JsonLiteral objects (with content=str and isString=false).
Additionally, an intriguing observation prompted me to raise this issue: when I encode this JsonElement back to a string, the values are quoted, introducing what appears to be inconsistent behavior.
To Reproduce
val jsonStr1 = """{"a": 1a}"""
val jsonTree = Json { isLenient = false }.parseToJsonElement(jsonStr1)
val jsonStr2 = Json { isLenient = false }.encodeToString(jsonTree)
if (jsonStr1 != jsonStr2) throw IllegalStateException()
Expected behavior
SerializationException is thrown when malformed input parsed or jsonStr1 == jsonStr2