Hi

Sorry for a delay.
I'm wondering would using JSON object annotations solve this problem. Jettison ships them too so perhaps we could've updated jettison to check if JSONObjects and if they're there then use them to serialize. It's on the map anyway - I didn't get the time yet to do it. Gary T - if you read it, do you think JSONObjects can help here ? If they do then the intermediate solution would be to temporarily create a custom provider on top of the one we ship, until we commit the fix to the trunk.

cheers, Sergey




Hi,

I'm using cxf 2.2 to provide a REST Service which produces XML and JSON. I
have a Dto which contains two String fields and two fields of type
Vector<String>.
What happens is, that all fields, that are declared after the first vector,
are returned as elements of this vector.

Example:

@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Someclass {
   String str1 = "str1";
   Vector<String> vec1 = new Vector<String>(); // contains elements
"vec1elem1" and "vec1elem2"
   String str2 = "str2";
   Vector<String> vec2 = new Vector<String>(); // contains elements
"vec2elem1" and "vec2leme2"
}

If I use XML as return value everything works fine. But JSON looks something
like this:
{"Someclass":{"str1":"str1","vec1":["vec1elem1","vec1elem2","str2","vec2elem1","vec2elem2"]}}

All following fields and all elements of following vectors are added to the
first vector.

What I tried was to set the AccessorType to NONE and add a @XmlElement
annotation to each field - this didn't change anything.

What works, is to add a @XmlList annotation to each vector. Then the fields
are interpreted correctly, but I don't really like the XmlList
representation.

Is there any way to fix this?

Thanks for your help,
Felix

--
View this message in context: 
http://www.nabble.com/Multiple-collections-in-JSON-Dto-mixed-up-tp22698194p22698194.html
Sent from the cxf-user mailing list archive at Nabble.com.


Reply via email to