Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BigDecimal support #812

Closed
dinee432 opened this issue Mar 16, 2016 · 2 comments
Closed

BigDecimal support #812

dinee432 opened this issue Mar 16, 2016 · 2 comments

Comments

@dinee432
Copy link

How do I specify to use bigdecimal to handle numbers in gson? Below is the sample code and sample json string that I am trying to convert to a map.

`Type type = new TypeToken<Map<String, Object>>() { }.getType();
  Map<String, Object> data = new Gson().fromJson(strInput, type);`

Sample Json string :

[{
"Type":"Test",
"Amount":100231212111.00,
}]

The result I am getting is a map with double value for Amount. Please help to resolve this issue

@lyubomyr-shaydariv
Copy link
Contributor

  • The JSON document structure you provided does not match the type you declared in the type token. It should be List<Map<String, Object>>.
  • Unfortunately, as of Gson 2.8.5 you cannot tell Gson to convert Object to a specific Number implementation.

@eamonnmcmanus
Copy link
Member

Fixed by #1290.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants