-
Notifications
You must be signed in to change notification settings - Fork 41
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
GH-43 Adds support for serialization of amount number as string #45
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs some readme change.
@@ -50,11 +60,15 @@ public void serialize(final MonetaryAmount value, final JsonGenerator generator, | |||
generator.writeEndObject(); | |||
} | |||
|
|||
static boolean numberAsStringDefault() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
@@ -16,6 +16,7 @@ | |||
|
|||
private final MonetaryAmountFormatFactory factory; | |||
private final FieldNames names; | |||
private final boolean numberAsString; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using a boolean, can we use our own implementation of Jackson's Feature types?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I initially implemented features the same way as jackson does, but then discarded it since I hope there will not be that many toggles at all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd still prefer a Feature enum.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean own or Jackson's? With Jackson's we have to fail if someone requests other feature beside WRITE_NUMBERS_AS_STRINGS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could implement ConfigFeature
ourselves, but I think what would be a better fit would be an enum:
public enum Style {
DECIMAL, STRING
}
I just found this: http://fasterxml.github.io/jackson-core/javadoc/2.8/com/fasterxml/jackson/core/JsonGenerator.Feature.html#WRITE_NUMBERS_AS_STRINGS
|
I have seen it. |
@whiskeysierra RFC |
True, but client at least have an option right now already. |
@whiskeysierra I dont get your point, could you explain? |
If somebody want to use strings instead of decimal number he/she can already use Jackson's built-in support for that (they might be ok with all numbers being strings). |
Ah, so you want default value to be inherited from that configured jackson feature? |
Once WRITE_NUMBERS_AS_STRINGS is enabled it will overrule anything in this PR. |
And this is desired, isnt it? |
Or do you want to say this feature is not needed at all? |
Well, I'm ambivalent. On the one hand I'd say it's not needed since Jackson kind of already supports it.
On the other hand I see the value in that. That feature however could be understood in a more general concept: It would be nice to enable/disable certain features for certain types/subtypes/object graphs/... It does not apply to monetary amounts alone, but could be useful to others as well. No idea how to tackle this, though. |
After some consideration we decided to implement it as an pluggable interface instead of feature toggle. |
Closing in favor of #48 |
Fixes #43