Closed yamin-oanda closed 1 year ago
Thanks for the heads up.
We added a new API to easily enable to handle BigDecimal value in String as follows:
ObjectMapper objectMapper = new MessagePackMapper().handleBigDecimalAsString();
This feature has been released in 0.9.4.
See https://github.com/msgpack/msgpack-java/tree/develop/msgpack-jackson#serialize-and-deserialize-bigdecimal-as-str-type-internally-in-messagepack-format for details.
This is a follow-up to #204
Originally it was decided to encode BigDecimals as either integer or float for reasons. This is actually almost never what we want. The only safe and reasonably cross-platform way to serialize BigDecimal is by encoding it as a string. We can see a slew of issues that happened because of the original choice: #231, #278, #526, #534, #549.
Now I understand that we can't just break backward-compatibility of the library and change the default. And I see that a note has been added about setting an option to use string encoding: https://github.com/msgpack/msgpack-java/blob/develop/msgpack-jackson/README.md#serialize-and-deserialize-bigdecimal-as-str-type-internally-in-messagepack-format
However I believe this note does not go far enough. We should warn users in bold text not to use double encoding for BigDecimal going forward as it is a historical design mistake, and to instead always set the option to use the string encoding.