FasterXML / jackson-dataformat-xml

Extension for Jackson JSON processor that adds support for serializing POJOs as XML (and deserializing from XML) as an alternative to JSON
Apache License 2.0
574 stars 222 forks source link

Make empty tags configurable during serialization #640

Open Croway opened 9 months ago

cowtowncoder commented 9 months ago

Ok, I can see what this PR does, but I am not quite sure how it makes any sense as a feature.

Croway commented 9 months ago

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. If you think this usecase does not make sense, could you suggest how to implement it? (custom Serializer?)

cowtowncoder commented 9 months ago

@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 "[]"). This would need to be configuration on XmlFactory (through XmlFactoryBuilder -- it has _nameForTextElement to kind of show how to do this I think). Such general purpose functionality could be useful for other things too I suspect.

Croway commented 9 months ago

Thanks for the hint @cowtowncoder I have updated the PR.

cowtowncoder commented 9 months ago

@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 cla at fasterxml dot com. And once I get it I can proceed.

Looking forward to merging this new feature!

pjfanning commented 4 months ago

@Croway Did you ever fill in the CLA? The 2.18.0 RC1 is in a few weeks.

Croway commented 4 months ago

@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.

cowtowncoder commented 3 months ago

Quick note: PR would need to be re-based against 2.18 as well.