google / google/gson

JsonElement's getAsInt() doesn't throw an Error when converting an too big exponential value

Open
#630 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
24.2k
Forks
4.5k
Avg merge
6d 4h
Merged PRs (30d)
12

Description

```
What steps will reproduce the problem?
Example:
String json = "{\"id\":1e10000010}";
JsonParser parser = new JsonParser();
JsonObject jsonObj = (JsonObject) parser.parse(json);
Date before = new Date();
Integer Id = jsonObj.get("id").getAsInt();
Date after = new Date();
Long diff = after.getTime() - before.getTime();
System.out.println("Id: " + Id + " Milliseconds: " + diff);

Output: Id: 0 Milliseconds: 9714

What is the expected output? What do you see instead?
It should throw an error, but instead returns 0 after a long time.

What version of the product are you using? On what operating system?
Gson 2.3.1
Ubuntu 14.04
```

Original issue reported on code.google.com by `Sebastia...@gmail.com` on 4 Mar 2015 at 2:41

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.