cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ilya Kramer (JIRA)" <j...@apache.org>
Subject [jira] Created: (CXF-3341) Bad JSON marshalling of List<String> object
Date Wed, 16 Feb 2011 11:06:57 GMT
Bad JSON marshalling of List<String> object
-------------------------------------------

                 Key: CXF-3341
                 URL: https://issues.apache.org/jira/browse/CXF-3341
             Project: CXF
          Issue Type: Bug
          Components: JAX-RS
    Affects Versions: 2.3.2
         Environment: Ubuntu 10.04 64Bit Server
            Reporter: Ilya Kramer


Wrong result returned by marshalling an object with List<String>. The result some why
depends on the actual amount of elements on the list.

for example , this code

{code:xml} 
package ldtv.api.models;

import java.util.List;


import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "user")
public class LDTVSites {
	
	private List<String> sites;

	public LDTVSites(List<String> sites) {

		setSites(sites);

	}

	public LDTVSites() {
	}

	public void setSites(List<String> listSites) {
		this.sites = listSites;
	}
	
	@XmlElement(name="sites")
	public List<String> getSites(){
		return sites;
	}

}
{/code}

if getSites returns a list with single result, the result of the function will be
{"user":{"sites":"string"}}

whereas if the result is two strings in the list , the output will be
{"user":{"sites":["string","string2"]}}

this makes some sense in XML , it shouldn't be so in JSON since the values of the two expressions
is different

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message