-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
SerializationFeature.WRITE_BIGDECIMAL_AS_PLAIN
not taken into account when serializing BigDecimal
as String
#2323
Comments
You may be misunderstanding function of To force serialization of (all) numbers as JSON Strings, you can use |
Ok sorry, but that would force any numbers being returned as strings? Couldn't I enable this feature for BigDecimals only? |
@sddakoty That would force all numbers as Strings on output. Another method that should work would be use of public class POJO {
@JsonFormat(shape = JsonFormat.Shape.STRING)
public BigDecimal value;
} and you can actually define it for all values of a type, see "config overrides" on: https://medium.com/@cowtowncoder/jackson-2-8-features-5fc692887944 for details. Hope this helps! |
Could you give an example how I apply this
If yes, what would it use internally? |
@sddakoty Yes I think that should be it, wrt String output. However looking at code ( So it may actually be that this would not work if you want to avoid scientific notation. I'll reopen this issue, reword it, to suggest that combination should be taken into account (so that you would combine the feature AND format to get what you want). |
SerializationFeature.WRITE_BIGDECIMAL_AS_PLAIN
not taken into account when serializing BigDecimal
as String
Got ok. So atm the only solution would be as follows, eg:
Indeed it would be great I one could configure this effect directly through some serialization feature. |
@sddakoty Almost, but you can actually remove that if check there: serialize() method is never called with And yes I hope I find time to implement this in near future. |
Actually, I think it already works; fixed with #2230, to be included in 2.10 (and is included in |
So what is the correct settings and configuration now with the fix, if I'd just want |
@membersound Usage question belong to user mailing list. This issue is specifically ensuring that setting |
The following test should convert a
BigDecimal
number to"3.033"
string in json. But in fact it only converts it to double.Result:
jackson-databind-2.9.8
The text was updated successfully, but these errors were encountered: