You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
There is no possibility to set jsonNodeFactory when working with patches. #110
org.junit.ComparisonFailure: expected:<25[.000]> but was:<25[]>
Expected :25.000
Actual :25
Is it possible to inject the behaviour I am after?
The JacksonUtils that JsonMergePatch is using sets the factory to JsonNodeFactory.instance and I cannot see a way around this. I would prefer to use the JsonNodeFactory.decimalsAsIs for my specific case.
This also applies to the JsonDiff.asJson(older, newer) with the same behaviour as the above example.
No unfortunately not. I changed my schemas to string instead of number.
However I did successfully make a version without JacksonUtils but it did not feel like the correct solution.
Hm... in my case I serialize and deserialize some classes with BigDecimal fields using objectmapper. I never had any problems with that, no loss of trailing zeroes.
I only encountered the problem when converting the object to JsonNode (to be used with JsonPatch)
Activity
MCakrt commentedon Nov 4, 2021
I've just come across this problem, too :(
Let me know if you find a solution.
gabrielsson commentedon Nov 4, 2021
No unfortunately not. I changed my schemas to string instead of number.
However I did successfully make a version without JacksonUtils but it did not feel like the correct solution.
MCakrt commentedon Nov 4, 2021
Hm... in my case I serialize and deserialize some classes with BigDecimal fields using objectmapper. I never had any problems with that, no loss of trailing zeroes.
I only encountered the problem when converting the object to JsonNode (to be used with JsonPatch)
JsonNode node = objectMapper.convertValue(someObjectWithBigDecimalField, JsonNode.class);
Then the trailing zeroes were trimmed.
But in this case, I just added .setNodeFactory(JsonNodeFactory.withExactBigDecimals(true) and everything works as expected.
So my problem is different from yours. My problems was that BigDecimals got trimmed while you have problem with string->BigDecimal deserialization.