Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Number jsons #219

Closed
BraisGabin opened this issue Mar 28, 2022 · 4 comments
Closed

Support Number jsons #219

BraisGabin opened this issue Mar 28, 2022 · 4 comments

Comments

@BraisGabin
Copy link
Contributor

humanReadableSerializerModule should allow to parase things like:

"price": {
    "amount": 12.34,
    "currency": ""
}

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 using 12.34.

From backend I'm receiving that and with Moshi I hadn't any problem. On moshi I read 12.34 as a String (even it is a number in the json) and I parse it to BigDecimal.

@ionspin
Copy link
Owner

ionspin commented Mar 28, 2022

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 Kotlin/kotlinx.serialization#1051
Specifically this comment Kotlin/kotlinx.serialization#1051 (comment)

I'm closing this issue as there is nothing to on our side at the moment.

@ionspin ionspin closed this as completed Mar 28, 2022
@BraisGabin
Copy link
Contributor Author

Thanks for the fast replay! It seems that they are tracking this "feature" here: Kotlin/kotlinx.serialization#1405

@ionspin
Copy link
Owner

ionspin commented Mar 28, 2022

Good to know, thanks!

@aSemy
Copy link

aSemy commented Oct 18, 2022

Hi, just a quick heads up that I'm working on supporting BigDecimal/BigInteger in this PR Kotlin/kotlinx.serialization#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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants