jackson-dataformat-xml icon indicating copy to clipboard operation
jackson-dataformat-xml copied to clipboard

Make empty tags configurable during serialization

Open Croway opened this issue 1 year ago • 8 comments

Croway avatar Feb 19 '24 14:02 Croway

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

cowtowncoder avatar Feb 19 '24 19:02 cowtowncoder

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?)

Croway avatar Feb 19 '24 19:02 Croway

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

cowtowncoder avatar Feb 19 '24 19:02 cowtowncoder

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

Croway avatar Feb 20 '24 10:02 Croway

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

cowtowncoder avatar Mar 02 '24 04:03 cowtowncoder