klaxon icon indicating copy to clipboard operation
klaxon copied to clipboard

Klaxon fails to convert Int/Long to BigInteger

Open Myaamori opened this issue 4 years ago • 0 comments

Running

data class MyNumber(val number: BigInteger)

data class MyList(val list: List<MyNumber>)

Klaxon().parse<MyList>("""{"list": [{"number": 123456789000}, {"number": 123456789000000000000}]}""")

gives me the following error:

Unable to instantiate MyNumber:
    Parameter number: expected java.math.BigInteger but received java.lang.Long (value: 123456789000)

If I replace BigInteger in the definition above with Long and otherwise keep the code the same I get:

Unable to instantiate MyNumber:
    Parameter number: expected kotlin.Long but received java.math.BigInteger (value: 123456789000000000000)

Using Klaxon 5.2.

Myaamori avatar May 23 '20 02:05 Myaamori