Wie die Serialisierung von java-Objekt als xml-Attribut mit jackson?

gibt es eine Möglichkeit zum serialisieren eines java-var (z.B. int) über jackson als xml-Attribut?
Ich kann nicht finden, eine spezifische jackson-oder json-annotation (@XmlAttribute
@javax.xml.binden.Anmerkung.XmlAttribute) um dies zu realisieren.

z.B.

public class Point {

    private int x, y, z;

    public Point(final int x, final int y, final int z) {
        this.x = x;
        this.y = y;
        this.z = z;
    }

    @javax.xml.bind.annotation.XmlAttribute
    public int getX() {
        return x;
    }
    ...
}

Was ich will:

<point x="100" y="100" z="100"/>

aber alle, die ich habe ist:

<point>
    <x>100</x>
    <y>100</y>
    <z>100</z>
</point>

Gibt es einen Weg, um Attribute statt Elemente?
Danke für die Hilfe!

  • Es ist kein problem mit den int-Datentyp. Was immer ich auch versuchte, ich bekam nur noch xml-Elemente statt Attribute.
InformationsquelleAutor Divine | 2013-02-05
Schreibe einen Kommentar