Open OndraZizka opened 3 years ago
Not sure if it helps but it is possible to specify "root name" to use via ObjectWriter
. In Java it'd be like:
ObjectMapper mapper = ...;
ObjectWriter w = mapper.writer()
.withRootName("transactions"); // or using `PropertyName` if you need to pass XML namespace too
byte[] xml = w.writeValueAsBytes(value);
and that will override outermost xml element name.
Not sure whether to move to Kotlin or XML project... possibly Kotlin, will transfer.
Is your feature request related to a problem? Please describe. With Spring REST, I want to have this XML:
For that, I hoped I could use some very simple construct, like this:
But as you can see, I tried a lot, but the closest I got is
<><transactions></>
which is, I assume, due to an empty class name Jackson sees.Describe the solution you'd like Make this:
produce this:
Usage example See above - brief syntax for returning a List<...> from an endpoint.
Additional context
I didn't even manage to persuade Jackson to name the wrapper as I want using annotations. It insisted on using the class name. So I had to rename it to
class transactions
.But that's a different story.