I use @XmlJavaTypeAdapter
to transform Map
objects into List
when marshalling (and vice versa when u
Note: I'm the EclipseLink JAXB (MOXy) lead and a member of the JAXB (JSR-222) expert group.
You could use the @XmlPath(".")
extension in MOXy to map this use case. Specifying "."
as the path indicates that the contents of the child should be written into the parent objects element.
import java.util.HashMap;
import javax.xml.bind.annotation.*;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.eclipse.persistence.oxm.annotations.XmlPath;
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Foo {
@XmlJavaTypeAdapter(MyMapItemAdapter.class)
@XmlPath(".")
Map<String, MapItem> map = new TreeMap<String, MapItem>();
}
Full Example
For More Information