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 key or value in Json is not quoted (e.g. one wanted to parse a data in lenient mode, but forgot to turn it on),
the position points to the end of such value, but message mentions the beginning:
To Reproduce
@Test
funlenientIncorrect() {
val input1 ="""{boxed:str}"""val input2 ="""{"boxed":str}"""val ser = serializer<Box<String>>()
Json.decodeFromString(ser, input2)
}
Expected behavior
Parsing input2 gives
kotlinx.serialization.json.internal.JsonDecodingException: Unexpected JSON token at offset 11: Expected quotation mark '"', but had 'r' instead at path: $.boxed
JSON input: {"boxed":str}
although message should be 'had s instead' and position 8, to point at the beginning of the string where quotation is expected.
Parsing input1 gives
JSON input: {boxed:str}
Same here: should have offset=1 and message 'had b instead'.
Reason: consumeStringLenienthere advances position and doesn't roll it back.
Environment
Kotlin version: 1.8.21
Library version: 1.5.1
Kotlin platforms: JVM
The text was updated successfully, but these errors were encountered:
To avoid cryptic and incorrect ones, such as `Expected quotation mark '"', but had '"' instead` or `unexpected token: 10`.
Fixes#2360Fixes#2399
Also remove @PublishedApi from BATCH_SIZE to remove it from public API dump.
To avoid cryptic and incorrect ones, such as `Expected quotation mark '"', but had '"' instead` or `unexpected token: 10`.
Fixes#2360Fixes#2399
Also remove @PublishedApi from BATCH_SIZE to remove it from public API dump.
Describe the bug
If key or value in Json is not quoted (e.g. one wanted to parse a data in lenient mode, but forgot to turn it on),
the position points to the end of such value, but message mentions the beginning:
To Reproduce
Expected behavior
Parsing
input2
givesalthough message should be 'had s instead' and position 8, to point at the beginning of the string where quotation is expected.
Parsing
input1
givesSame here: should have offset=1 and message 'had b instead'.
Reason:
consumeStringLenient
here advances position and doesn't roll it back.Environment
The text was updated successfully, but these errors were encountered: