Serializing BigDecimal value using GSON

Viewed 8290

here is my code:

System.out.println(GSON.toJson(new BigDecimal(10.12)));

and the output is:

10.1199999999999992184029906638897955417633056640625

Is it possible to limit the precision of BigDecimal value that GSON serialize? i.e. my expected output of serialized value is:

10.11
3 Answers
Related