Igor
Igor

Reputation: 866

Replace Xstream facilities

After upgrading Xstream to 1.4.8 I noticed that XstreamConverter and XstreamRepresentation were deprecated.

Two questions:

  1. Should I substitute my xstream annotations?
  2. What Converter and Representation should I use instead?

The annotations I currently use are:

How can I achieve XML formatted response using Jackson?

Upvotes: 1

Views: 867

Answers (1)

Thierry Boileau
Thierry Boileau

Reputation: 866

We plan to keep only the Jackson extension which handles several formats, mainly for the sake of simplicity. This removal is planned for release 3.0 of the framework.

Could you send us the kind of annotations you are using? we can help you to find substitute. If your are using the XStreamAlias annotation at the class level, use the JacksonXmlRootElement annotation. If your are using the XStreamAlias and the XStreamAsAttribute annotation at the property level, use the JacksonXmlProperty annotation. For example:

@JacksonXmlRootElement(localName = "MyContact")
public class Contact {
   @JacksonXmlProperty(localName = "firstName")
   private String name;

   @JacksonXmlProperty(isAttribute = true)
   private String attr;

   public String getAttr() {
       return attr;
   }

   public void setAttr(String attr) {
      this.attr = attr;
   }

   public String getName() {
       return name;
   }

   public void setName(String name) {
       this.name = name;
   }

}

Here is a page that describes all annotations dedicated to XML transformations: https://github.com/FasterXML/jackson-annotations/wiki/Jackson-Annotations

Having said that, it is still possible to keep the xstream extension in your own code, even in the future, while the API of the 3.0 version of the is compatible with the one used by your version of the xstream extension.

Upvotes: 1

Related Questions