Skip to content

Decoding a JSON integer value containing an exponent and a decimal point #2972

Open
@illarionov

Description

@illarionov

Currently, numeric JSON values ​​containing a decimal point cannot be decoded as integer types.
An example of such values: 1.0, 1.0E1, -1.5E3, 0.5e2.

Decoding it as long fails with an error:

println(Json.decodeFromString<Int>("1.0e1"))
kotlinx.serialization.json.internal.JsonDecodingException: Unexpected JSON token at offset 0: Unexpected symbol '.' in numeric literal at path: $

It would be beneficial if these values could be decoded. Alternatively, it should be documented that such form is not supported.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions