[
https://issues.apache.org/jira/browse/CXF-3341?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12995257#comment-12995257
]
Sergey Beryozkin commented on CXF-3341:
---------------------------------------
Unfortunately this is a won't fix issue due to the underlying Jettison
limitation.
The workaround is documented here:
http://cxf.apache.org/docs/jax-rs-data-bindings.html#JAX-RSDataBindings-DealingwithJSONarrayserializationissues
thanks
> 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:title=LDTVSites.java|borderStyle=solid}
> 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
> {code}
> {"user":{"sites":"string"}}
> {code}
> whereas if the result is two strings in the list , the output will be
> {code}
> {"user":{"sites":["string","string2"]}}
> {code}
> 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