Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] android – Request in Retrofit returns inappropriate data

Posted on November 11, 2022 By

Solution 1 :

You can use Long type for that (20000000).

In my project I am getting below json and I used long type in my model class

JSON

{
    "success": {
        "value": 20000000
    }
}

Models class

public class Success {

    @SerializedName("value")
    @Expose
    private Long value;

    public Long getValue() {
        return value;
    }

    public void setValue(Long value) {
        this.value = value;
    }

}

Solution 2 :

Check this same question How to prevent Gson from converting a long number (a json string ) to scientific notation format?

This May help you…

Problem :

My problem is that I make a request in Android application which should return BigDecimal, instead, I got 2.0E7 value. I tried make this request in Postman and it returns 20000000 (proper value). I changed type of value in my data class to BigDecimal and to String and in both cases I got 2.0E7. I need to get the proper value. Can someone help in solving this issue?

Comments

Comment posted by Manohar

are you using gson converter ?

Comment posted by Asset Bekbossynov

Yes I am using gson converter

Comment posted by github.com/google/gson/issues/968

Gson has this problem see

Comment posted by Asset Bekbossynov

Did not help me

Comment posted by Asset Bekbossynov

I used String, but it still returns 2.0E7

Comment posted by Rajendra Dabhi

I have the same problem previously and its been resolved by just changing its type to string type.

READ  [FIXED] android - 'java.lang.String java.lang.Object.toString()' on a null object reference
Powered by Inline Related Posts
Android Tags:android, type-conversion, types

Post navigation

Previous Post: [FIXED] activity_main.xml for android studio stuck on loading
Next Post: Can a beginner learn Moonlight Sonata 1st Movement?

Related Posts

[FIXED] android – UI not loading until I resize the app window or move it to floating window Android
[FIXED] android – How can I return value from callback in Kotlin? Android
[FIXED] Android YouTube SDK – video not playing in some android devices Android
[FIXED] Android adds item on back stack even when its not specified Android
[FIXED] UDP Sending via android cannot be automatic Android
[FIXED] android – How to write in firebase database from another project? Android

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • Which is stronger 19 gauge or 23 gauge?
  • Does BMW still use GM transmissions?
  • Is primary or secondary market research better?
  • What does it mean when ADT says low battery?
  • Can a baby sleep on a regular mattress?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme