Hi

What Jettison version ? I think Jettison 1.3.2 did fix a similar issue but not too sure...

Sergey
On 04/10/12 17:32, sireesh wrote:
Hi,
I'm trying to unmarshal a json  into a Java object using JSONProvider.
However, in the unmarshalled object, I'm not getting all the elements
unmarshalled into the list property.

*JSON used:*
{
     "Header": {
         "ProductIdentifier": "WLW",
         "Version": "2"
     },

     "Keys":[{"RegistrationKey":"1234567abcd"}, {"RegistrationKey":"789xyz"}]
}

*My jsonProvider spring configuration:*
     <bean class="org.apache.cxf.jaxrs.provider.JSONProvider">
         <property name="inTransformElements">
             <map>
                 <entry key="*" value="{Mynamespace}*" />
             </map>
         </property>
         <property name="supportUnwrapped" value="true" />
     </bean>

*JAXB annotations for the top element*
//removed annotations for readability
public class ClientRequest {

     @XmlElement(name = "Header", namespace = "Mynamespace")
     private ReqHeader header;

     @XmlElementWrapper(name="Keys", namespace = "Mynamespace")
     @XmlElement(name="RegistrationKey", namespace = "Mynamespace")
     private List<String>  keys = new ArrayList<String>();
}

*code for unmarshalling:*
Object  obj = jsonProvider.readFrom((Class)ClientRequest.class, null, null,
null, null, inputStream);

In the unmarshalled object, the keys property is being mapped as arraylist
but with only one element, the last element("789xyz").
If I interchange the order of the RegistrationKey elements, then the other
key(1234567abcd) is being mapped. So, the size of the keys arraylist is 1.
I was expecting the size of keys to be 2 as you can see in json there are
two RegistrationKey elements.

Can someone please help me, if I've missed any configuration of jaxb or
jsonprovider?

Thanks,
Kiran Sireesh




--
View this message in context: 
http://cxf.547215.n5.nabble.com/JSONProvider-unable-to-unmarshal-json-containing-list-of-elements-tp5715651.html
Sent from the cxf-user mailing list archive at Nabble.com.


--
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Reply via email to