Search code examples
javaxmljsontransformationpojo

A tool for transforming POJO to XML and JSON, based on xml-mapping is needed


I need an open-source tool which can convert POJOs to XML and JSON strings.

Jersey (and probably other JAX-RS implementations) would fit these requirements if mappings could be configured through xml-files but not through annotations.

Is there anything suitable?


Solution

  • POJO to XML

    JAXB is the Java standard (JSR-222) for converting Java objects to/from XML (I am a member of the JAXB expert group):

    POJO to JSON

    People have been using JAXB with Jettison to produce JSON. This is how Jersey (JAX-RS reference implementation) converts POJOs to JSON by default.

    XML Configuration

    If you require the ability to configure the metadata via XML, then you can use EclipseLink JAXB (MOXy), I'm the MOXy tech lead: