0

Hello I am using Gson parser, in my class there is no double variable used though I am getting Invalid Double Exception, where the value comes as emtpty string but there is no double variable in my class structure.

Can anyone suggest what to do?

Siddhesh Pawar
  • 259
  • 4
  • 24
  • post logcat ... – Jyoti JK May 21 '18 at 09:48
  • logcat is just showing invalid double : "" – Siddhesh Pawar May 21 '18 at 09:49
  • please check full stacktrace of the exception . Is It showing just a single line ? And post your related code too – Jyoti JK May 21 '18 at 09:50
  • : com.google.gson.JsonSyntaxException: java.lang.NumberFormatException: Invalid double: "" : at com.google.gson.internal.bind.TypeAdapters$7.read(TypeAdapters.java:227) : at com.google.gson.internal.bind.TypeAdapters$7.read(TypeAdapters.java:217) : at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:129) : at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220) – Siddhesh Pawar May 21 '18 at 09:58
  • check [this](https://stackoverflow.com/questions/25140170/gson-jsonsyntaxexception-java-lang-numberformatexception-invalid-double) and [this](https://stackoverflow.com/questions/18672456/java-lang-numberformatexception-invalid-double) – Jyoti JK May 21 '18 at 10:00

1 Answers1

0

Seems like you are trying to handle response using Gson and your pojo class model has datatype Double but response returns value as "" which is String as default value.

Please make your default value as 0 for the same field and your problem will get resolved. If there is a backend guy working for APIs ask him to set default value as 0 for such fields.

Deep Patel
  • 2,584
  • 2
  • 15
  • 28