12

Similar to JAXB generating JAXB classes to a given XSD, does Jackson provide any utility to generate Jackson classes from XSD or JSON.

JAXB class geberator has generated a set of classes for XSD schema defined. For example, for polymorphic types JAXB has the following annotation to identify the name based on XML Element name.

@XmlElements({
    @XmlElement(name = "Dog", type = Dog.class),
    @XmlElement(name = "Cat", type = Cat.class)
})
protected List<Animal> animal;

Is it possible to create similar classes in Jackson. ie., to identify the type based in XML element name.

dinup24
  • 1,432
  • 3
  • 14
  • 24

1 Answers1

0

Have you looked at the similar question on StackOverflow? They may fully answer your question or contribute greatly to that.

  • This first link shows how to generate a json schema from an xml schema through java
  • Once you have the Json schema, This second link shows how to generate the classes from the json schema using jsonschema2pojo
Community
  • 1
  • 1
alainlompo
  • 4,340
  • 3
  • 31
  • 41
  • 1
    xsd to java is something different than xsd to json to java. Wrapping tags will be lost for example and the so generated code will be clumsy and too broad. – Hannes Nov 16 '20 at 19:23