users@jersey.java.net

[Jersey] Re: JAXB marshalling creates duplicate elements

From: ripsi <ripsi_1_at_yahoo.com>
Date: Fri, 16 Mar 2012 14:10:46 -0700 (PDT)

Had the same issue.

I was using a class to create an array of JSON strings to pass to a REST
endpoint so I could do bulk adds, updates, etc...

Had to comment out >>>

@XmlElementWrapper above the List declaration that would store all my JSON
objects (client objects)

public class RestClientList {
        
        // WTF, this causes duplicates to be created below!
        //_at_XmlElementWrapper(name="client")
        private List<BasicRestClient> clientList;

        public List<BasicRestClient> getClient() {
                return this.clientList;
        }

        public void setClient(List<BasicRestClient> clients) {
                
                if(clients == null)
                        clients = new ArrayList<BasicRestClient>();
                
                this.clientList = clients;
        }
        
        public void addClient(BasicRestClient restClient) {
                
                if(clientList == null)
                {
                        clientList = new ArrayList<BasicRestClient>();
                }
                
                this.clientList.add(restClient);
        }

}

--
View this message in context: http://jersey.576304.n2.nabble.com/JAXB-marshalling-creates-duplicate-elements-tp5796159p7380256.html
Sent from the Jersey mailing list archive at Nabble.com.