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
If you try to write infinite float or double values in an object, the serializer ends up writing an unquoted "Infinity".
A test that demonstrates this:
import com.beust.klaxon.Parser
import com.beust.klaxon.json
import java.io.StringReader
import kotlin.test.Test
class AppTest {
@Test
fun testInfinity() {
val jsonString = json {
obj(Pair("val1", Float.POSITIVE_INFINITY))
}.toJsonString()
println("jsonString=$jsonString")
println(Parser.default().parse(StringReader(jsonString)))
}
}
This outputs jsonString={"val1":Infinity}
followed by the exception com.beust.klaxon.KlaxonException: Unexpected character at position 8: 'I' (ASCII: 73)
Note: For a negative infinity the result is jsonString={"val1":-Infinity}
I would not expect it to ever write invalid JSON. I believe it should, by default, either write a quoted "Infinity" or throw an exception.
The text was updated successfully, but these errors were encountered:
Version: 5.5
If you try to write infinite float or double values in an object, the serializer ends up writing an unquoted "Infinity".
A test that demonstrates this:
This outputs
jsonString={"val1":Infinity}
followed by the exception
com.beust.klaxon.KlaxonException: Unexpected character at position 8: 'I' (ASCII: 73)
Note: For a negative infinity the result is
jsonString={"val1":-Infinity}
I would not expect it to ever write invalid JSON. I believe it should, by default, either write a quoted "Infinity" or throw an exception.
The text was updated successfully, but these errors were encountered: