简体   繁体   中英

How to generate Json compatible POJO from xsd

I have been using xsd to prepare data transfer model. By now we were ok to use XML format and hence were using xjc to generate the same (using maven plugin).

Now we need to move way from XML and use Json. Is there a plugin or better way with which u still use xsd and generate Json compatible model with proper annotations like @JsonRootName, @JsonInclude etc.

Jackson 2 is able to recognize JAXB annotations (which are generated by xjc): https://github.com/FasterXML/jackson-modules-base/tree/master/jaxb

So by using Jackson as preferred serializer, all your existing Pojo's will automatically - and with no cost - become JSON friendly !

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM