google / google/gson

LazilyParsedNumber parsing of integers

Open
#996 1 comment 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

I want to process a vector of integers. For that, I get each JsonElement from the JsonArray and use getAsInt() to obtain its integer value.

However, if the value is, say, 6.7, it does not generate an exception, it returns 6 (this was a real bug in a configuration file, where 6,7 was by mistake written as 6.7).

This happens because the getInt() method of LazilyParsedNumber uses BigDecimal to parse the text and getInt() to get some integer value ou of it. Shouldn't it use BigInteger instead of BigDecimal?

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.