users@jaxb.java.net

Marshalling empty lists as null

From: poeta simbolista <poetasimbolista_at_gmail.com>
Date: Tue, 28 Jul 2009 07:26:39 -0700 (PDT)

Hi,

I have an issue. I have the following object:

public class IntegerList {

        private List< Integer> list = new ArrayList<Integer>();
        
        public List<Integer> getList() {
                return list;
        }

        public void setList(List<Integer> list) {
                this.list = list;
        }
}
That is, a plain Integer List.
When I JSON this, if the list is empty (or null), the only JSON it generates
is the String

null

which is not JSON-compliant.
I understand the root element is null since the child elements are null or
empty - but I'd prefer to have an empty JSON than a plain "null" String.
E.g. an empty JSON like

{}


I'm using Jersey with jaxb 2.1.10.
natural() JSONConfiguration

Thanks

-- 
View this message in context: http://www.nabble.com/Marshalling-empty-lists-as-null-tp24698774p24698774.html
Sent from the java.net - jaxb users mailing list archive at Nabble.com.