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
568 stars 221 forks source link

Suggestion: serializing primitive values as attributes by default #320

Open dagnelies opened 5 years ago

dagnelies commented 5 years ago

It would be nice if primitive values were serialized as attributes by default ...or if there was a flag to do that.

Currently, the generated XML is either very verbose or you need lots of annotations everywhere.

cowtowncoder commented 5 years ago

That might make sense, although my concern would be that there are often minor differences in preferences, so although immediate decision of primitives might be simple enough, questions like "how about matching Wrappers?", "I want same for Strings", "Why not Date/Time values too" would probably start soon.

What might make sense would be offering pluggability of object that can decide for "unmarked" properties (i.e. nothing to indicate preference) which way to go. And perhaps provide a default implementation for special case of primitives.