Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Jackson2 based XML serialization/deserialization [SPR-11785] #16407

Closed
spring-projects-issues opened this issue May 15, 2014 · 4 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented May 15, 2014

Sébastien Deleuze opened SPR-11785 and commented

It is basically a MappingJackson2HttpMessageConverter where we register a JacksonXmlModule. It could allow users to setup easily a XML + JSON webservice supporting filtering thanks to JsonView.

It is also a nice alternative to Jaxb2 since it allows to get XML support without @XmlRootElement annotations.

It would not impact existing Jaxb2 support since it can be activated only if JacksonXmlModule class from jackson-dataformat-xml JAR module is detected on the classpath.


Issue Links:

Referenced from: commits ebc726a, 6665634

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Could we also do this as a flag on MappingJackson2HttpMessageConverter itself, or even let it happen automatically there if jackson-dataformat-xml is on the classpath?

Juergen

@spring-projects-issues
Copy link
Collaborator Author

Sébastien Deleuze commented

We could, and it was in fact my first intention. But MappingJackson2HttpMessageConverter package is org.springframework.http.converter.json, and I was not confortable with the idea to put XML related functionalities in it.

That's why I ended up with the following proposal:

  • Common code in org.springframework.http.converter.AbstractMappingJackson2HttpMessageConverter
  • JSON converter : org.springframework.http.converter.json.MappingJackson2HttpMessageConverter
  • XML converter : org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter
  • +1 for automatic registration when jackson-dataformat-xml is in the classpath

If we could move MappingJackson2HttpMessageConverter to org.springframework.http.converter package, staying with a single class would be perfect, but I don't know if we can do a such breaking change. Do you think we could, or is it fine for you to put XML related code in org.springframework.http.converter.json.MappingJackson2HttpMessageConverter ?

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Fair enough, that's a good point. However, given the options, I'd rather put the support into MappingJackson2HttpMessageConverter itself, interpreting the subpackage name as "primarily json oriented providers" (or as an abbreviation for j-ack-son) ;-) Seriously, I don't think it's worth a convoluted split here, in particular given that Jackson2ObjectMapperFactoryBean lives in the json subpackage as well and is probably equally useful for the jackson-dataformat-xml case.

Juergen

@spring-projects-issues
Copy link
Collaborator Author

Sébastien Deleuze commented

Thanks for your feedback ! Thinking more about that, Jackson itself use a lot of JSON historically related stuff (including configuration options) for XML serialization, so yes it is better to add support in existing MappingJackson2HttpMessageConverter. It may allow us to add other formats supported by Jackson more easily later if we want to.

I have updated the issue title accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants