Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 425
M.J. Avatar asked Mar 11 '19 08:03

M.J.


1 Answers

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 !

like image 177
TacheDeChoco Avatar answered Oct 26 '22 23:10

TacheDeChoco