Giter VIP home page Giter VIP logo

Comments (5)

nkiesel avatar nkiesel commented on May 12, 2024

I just learned that using

@Serializable data class Team(@XmlSerialName("members", "", "") val members: List<Person>, val colors: List<String> = listOf())

will produce the same output as Jackson. Thus, this is solved (with downside that I would have to repeat the parameter name). I still would like to get this w/o adding all the annotations.

from xmlutil.

pdvrieze avatar pdvrieze commented on May 12, 2024

The library was designed to provide a "natural" XML experience. In line with XML schema it is the type that provides the tag name, not the property of the tag. However, these are fundamentally choices. I would be open for pull requests that would make this behaviour configurable.

from xmlutil.

pdvrieze avatar pdvrieze commented on May 12, 2024

I've just released a version that uses a "policy" object to configure serialization. You may want to have a look at that. It would allow you to have a custom policy rather than using the annotations. Let me know if that works for you. I'll see at adding some more documentation for it as well. I may add a jackson compatibility policy to make it easier for people in your case. Btw. how does Jackson handle polymorphic values/lists?

from xmlutil.

pdvrieze avatar pdvrieze commented on May 12, 2024

I've added an example and documentation on how to use the policy to do this. Have a look: https://github.com/pdvrieze/xmlutil/blob/master/examples/JACKSON.md

It should solve your problem. I don't want to put this in the library proper as it isn't quite complete and may need a different approach for different cases.

from xmlutil.

nkiesel avatar nkiesel commented on May 12, 2024

Yes, that looks like a good approach. Thank you!

from xmlutil.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.