-
-
Notifications
You must be signed in to change notification settings - Fork 222
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
Make empty tags configurable during serialization #640
base: 2.17
Are you sure you want to change the base?
Conversation
@@ -559,6 +561,9 @@ private final String _collectUntilTag() throws XMLStreamException | |||
if (FromXmlParser.Feature.EMPTY_ELEMENT_AS_NULL.enabledIn(_formatFeatures)) { | |||
return null; | |||
} | |||
if (FromXmlParser.Feature.EMPTY_ELEMENT_AS_EMPTY_ARRAY.enabledIn(_formatFeatures)) { | |||
return JsonToken.START_ARRAY.asString() + JsonToken.END_ARRAY.asString(); |
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 am not sure how this makes sense -- all we get here is String "[]", which won't be further decoded?
Ok, I can see what this PR does, but I am not quite sure how it makes any sense as a feature. |
Hello, I have an usecase (mostly due to compatibility) that requires to have empty xml tags serialized as json empty array. |
@Croway I think this is unfortunately bit too specific to add as a general on/off feature. I suspect it would not be easy to implement as custom deserializer (but might be possible) I would be open to configuration setting that allows configuring value to return as any String (so in your case, you could set it as |
Thanks for the hint @cowtowncoder I have updated the PR. |
src/main/java/com/fasterxml/jackson/dataformat/xml/deser/FromXmlParser.java
Show resolved
Hide resolved
src/main/java/com/fasterxml/jackson/dataformat/xml/deser/FromXmlParser.java
Show resolved
Hide resolved
src/main/java/com/fasterxml/jackson/dataformat/xml/deser/XmlTokenStream.java
Outdated
Show resolved
Hide resolved
src/main/java/com/fasterxml/jackson/dataformat/xml/deser/XmlTokenStream.java
Outdated
Show resolved
Hide resolved
@Croway Ok I think this would work. Before merging, there is one small process part: we'd need CLA from: https://github.com/FasterXML/jackson/blob/master/contributor-agreement.pdf this only needs to be done once, before the first contribution and is good all future contributions. The usual way is to print, fill & sign, scan/photo, email to Looking forward to merging this new feature! |
@Croway Did you ever fill in the CLA? The 2.18.0 RC1 is in a few weeks. |
Hi @pjfanning I am truly sorry about this situation, but I am still waiting a response from my company legal team. |
Quick note: PR would need to be re-based against |
No description provided.