JsonMappingException: Type id handling not implemented for type org.javamoney.moneta.internal.JDKCurrencyAdapter (by serializer of type org.zalando.jackson.datatype.money.CurrencyUnitSerializer)when trying to deserialize type with CurrencyUnit. Any suggestions how to handle it ?
Hi everyone! I'm new here so let me know if I'm doing something wrong here.
I want to draw some community attention to my question on StackOverflow (https://stackoverflow.com/questions/61465836).
Thanks in advance for any feedback.
Hey there! I just stumbled upon
javax.money and it sounds like a useful thing to use. I work for a financial company and most systems we have store currency and amount in separate fields which can lead to all kinds of interpretation errors and leaves lot of room for bugs especially when converting amounts in to other currencies.
I've been using my own
Amount class which is basically just a tuple of a currency code
String and and a value
BigDecimal with some methods to do arithmetic and currency conversions, but I'd obviously rather use something standard.
I'm struggling to understand the API, however. It's obviously designed for more than just my use case, and it seems to have been designed to be able to plug in different implementations.
The simple case of creating a
MonetaryAmount however, already has me stuck. The example at
https://github.com/JavaMoney/javamoney-examples/blob/307feafd4b72bddeea95e2cbaa9db3a8ceeaa67a/console/javamoney-console-java8/src/main/java/org/javamoney/examples/console/java8/Person.java#L123 for example directly instantiates a
org.javamoney.moneta.Money. It seems that talking directly to the implementation kind of defeats the purpose of having an API in the first place.
Maybe somebody can give me some context like what the design philosophy was for
javax.money so I can get a feel for what to expect.
Also, can somebody confirm whether directly instantiating
org.javamoney.moneta.Money is indeed the correct way to do this, or if there is a factory-type way to to it? (I could only find
MonetaryAmountFactory.create() but there's no way to pass in the currency code and amount so I don't understand how that would work.)