Closed BraisGabin closed 2 years ago
Hi @BraisGabin as far as I am aware it's not possible to encode it that way without precision loss, and the limitation is on the KotlinX serialization side. You can see the issue regarding this here https://github.com/Kotlin/kotlinx.serialization/issues/1051 Specifically this comment https://github.com/Kotlin/kotlinx.serialization/issues/1051#issuecomment-812130020
I'm closing this issue as there is nothing to on our side at the moment.
Thanks for the fast replay! It seems that they are tracking this "feature" here: https://github.com/Kotlin/kotlinx.serialization/issues/1405
Good to know, thanks!
Hi, just a quick heads up that I'm working on supporting BigDecimal/BigInteger in this PR https://github.com/Kotlin/kotlinx.serialization/pull/2041.
I'm a contributor to KxS, not a maintainer, so I can't give any timescale, but hopefully it's soon 🤞
I'd like to be able to help implement support in in this library when it's available! As a preview, you can see the test I wrote for BigDecimal - I expect a serializer for BigNum will be similar https://github.com/Kotlin/kotlinx.serialization/pull/2041/files#diff-46d155dec31ebfaed1e644398258f05f18332f9af8454854f863c0100019eb41
humanReadableSerializerModule
should allow to parase things like:But right now it forces to use
"12.34"
. We shouldn't lose any precision by using a number of json. We shouldn't lose any precision by using12.34
.From backend I'm receiving that and with
Moshi
I hadn't any problem. On moshi I read12.34
as aString
(even it is a number in the json) and I parse it toBigDecimal
.