TypeAdapterFactory INTEGER_FACTORY will change INTEGER type to LONG type
- Dominant language
- Java
- Stars
- 24.2k
- Forks
- 4.5k
- Avg merge
- 6d 4h
- Merged PRs (30d)
- 12
Description
# Gson version
2.10.1
# Java / Android version
21
# Description
I try to get a JsonElement by toJsonTree method. but i found that when i use integer object as input, i will get a long object with method ```JsonElement.getAsNumber()```
I think this commit caused this problem:https://github.com/google/gson/commit/3e3266cf48f132928225e1561a6ae4cb5503d08f
Is this a bug or a feature?
## Expected behavior
use integer type as input, get integer type as output
## Actual behavior
use integer type as input, get long type as output
# Reproduction steps
```
@Test
public void test(){
Integer testNum = 1;
JsonElement jsonTree = new Gson().toJsonTree(testNum);
System.out.println(jsonTree.getAsNumber().getClass());
}
```
Contributor guide
Assessment
This issue has not been assessed yet.