square/moshi

Parse double to string; Uncontrollable accuracy

OCNYang opened this issue · 0 comments

Problem description:
I want to parse data like:

{price:66.00000}

I define the data classes:

@JsonClass(generateAdapter = true)
data class XBean(
    val price: String = "",
)

But I get the value of xBean.price, which is uncontrollable,

  • Sometimes it's "66.0";
  • Sometimes it is "66.00000";

It's confusing to me.

Expect:
I don't know if there's something wrong with my usage; Or the library itself exists;

  1. If there is a problem with my use, can you tell me the possible problems?
  2. If it is a characteristic of the library itself, please tell me clearly;