Hot questions for Handling NumberFormatException in Retrofit

Top 10 Java Open Source / Retrofit / Handling NumberFormatException

java.lang.NumberFormatException: Expected an int but was 0.6 at line 1 column 8454

Question: I'm using the retrofit library for my calls in a demo project.

I received the following error:

java.lang.NumberFormatException: Expected an int but was 0.6 at line 1 column 8454 path $.result.results.ads[2].acres

I understand that this is down to JSON.

I will show you the JSON it's getting caught in:

   {  
       "ad_id":739580087654,
       "property_type":"site",
       "house_type":"",
       "description":"Beautiful elevated 0.6 acre site",
       "price":135000,
       "square_metres":0,
       "acres":0.6,   <----------------------TRIPPING UP HERE
       "features":[  
          "Zoned residential",
          "within easy walk of coastal village of Spiddal",
          "with coastal views"
       ],
       "ber_rating":"",
       "tags":1
    },

I'm not that experienced with Retrofit so decided to learn and integrate on this project.

Answer: Try using a float or double instead of an int; 0.6 is not an integer, it is a decimal. Note that java automatically interprets decimals as doubles; an example of a float would be 0.6f.