parseDataToJsonElementOrDefault
fun parseDataToJsonElementOrDefault(data: String, json: Json? = null, default: () -> JsonElement? = null): JsonElement(source)
Attempts to parse the given string into a JsonElement. If the parsing fails due to a SerializationException, it falls back to returning a JsonPrimitive wrapping the original string.
Return
A JsonElement if parsing succeeds; otherwise, a JsonPrimitive containing the original string.
Parameters
data
The input string to be parsed into a JsonElement.