A
A
Anton2016-05-22 17:26:54
Android
Anton, 2016-05-22 17:26:54

What causes the error "com.google.gson.JsonSyntaxException: java.lang.NumberFormatException: Invalid double: ""?

Wrote an application where remote JSON is parsed.
When starting the application, an error pops up:

com.google.gson.JsonSyntaxException: java.lang.NumberFormatException: Invalid double: ""

It is connected, as I understand it, with the wrong format of double numbers.
Numbers appear in two places in the passed JSON double. Here is a piece:
[...],"first":0.0,"second":8.067,[...]
Removed all double numbers from JSON. Now this line is gone:
[...],"first":0.0,"second":8.067,[...]
The error still occurs.
There are prime numbers in JSON, there are NULL values.
How to fix this error?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton, 2016-05-22
@hummingbird

The problem was in one of the fields, which was supposed to contain an int value. Instead of it or null value was just "" (string).
Solved the problem like this:

private String year;
// [...]
public int getYear() {
    return Integer.valueOf(this.year);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question